Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 23 additions & 21 deletions dev/flat_dock_from_renv.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,11 @@ renv::snapshot(
prompt = FALSE)

# Create Dockerfile
dock_from_renv(lockfile = the_lockfile,
my_dock <- dock_from_renv(lockfile = the_lockfile,
distro = "focal",
FROM = "rstudio/verse",
out_dir = dir_build
FROM = "rstudio/verse"
)

my_dock$write(file.path(dir_build, "Dockerfile"))
# rstudioapi::navigateToFile(file.path(dir_build, "Dockerfile"))
unlink(dir_build)
```
Expand Down Expand Up @@ -71,28 +70,31 @@ writeLines(renv_file, file.path(dir_build, "renv.lock"))

# dock_from_renv ----
test_that("dock_from_renv works", {
skip_if_not(interactive())
# skip_if_not(interactive())
# Create Dockerfile
expect_error(
dock_from_renv(lockfile = the_lockfile,

out <- dock_from_renv(lockfile = the_lockfile,
distro = "focal",
FROM = "rocker/verse",
out_dir = dir_build
), regexp = NA)

)
expect_s3_class(out,"Dockerfile")
expect_s3_class(out,"R6")
# read Dockerfile
out$write(file.path(dir_build, "Dockerfile"))
dock_created <- readLines(file.path(dir_build, "Dockerfile"))
expect_equal(
dock_created[grep("renv.lock.dock renv.lock", dock_created)],
paste0("COPY ", dir_build, "/renv.lock.dock renv.lock")
expect_equal(dock_created[1], "FROM rocker/verse:4.1.2")

expect_length(
grep("install.packages\\(c\\(\"renv\",\"remotes\"", dock_created) , 1
)
expect_length(
grep("RUN R -e 'renv::restore\\(\\)'", dock_created), 1
)
dock_created[grep("renv.lock.dock renv.lock", dock_created)] <-
"COPY renv.lock.dock renv.lock"

# file.copy(file.path(dir_build, "Dockerfile"), "inst/renv_Dockefile", overwrite = TRUE)
# System dependencies are different when build in interactive environment?
skip_if_not(interactive())
file.copy(file.path(dir_build, "Dockerfile"), "inst/renv_Dockefile", overwrite = TRUE)
dock_expected <- readLines(system.file("renv_Dockefile", package = "dockerfiler"))
dock_expected[grep("renv.lock.dock renv.lock", dock_expected)] <-
"COPY renv.lock.dock renv.lock"

expect_equal(dock_created, dock_expected)
})
Expand All @@ -101,7 +103,7 @@ unlink(dir_build)

# repos_as_character ----
test_that("repos_as_character works", {
out <- repos_as_character(
out <- dockerfiler:::repos_as_character(
repos = c(
RSPM = paste0("https://packagemanager.rstudio.com/all/__linux__/focal/latest"),
CRAN = "https://cran.rstudio.com/")
Expand All @@ -113,14 +115,14 @@ test_that("repos_as_character works", {

# gen_base_image ----
test_that("gen_base_image works", {
out <- gen_base_image(
out <- dockerfiler:::gen_base_image(
distro = "focal",
r_version = "4.0",
FROM = "rstudio/r-base"
)
expect_equal(out, "rstudio/r-base:4.0-focal")

out <- gen_base_image(
out <- dockerfiler:::gen_base_image(
distro = "focal",
r_version = "4.0",
FROM = "rocker/verse"
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-dock_from_renv.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# WARNING - Generated by {fusen} from /dev/flat_dock_from_renv.Rmd: do not edit by hand

dir_build <- tempfile(pattern = "renv")
dir.create(dir_build)

Expand Down Expand Up @@ -82,3 +84,4 @@ test_that("gen_base_image works", {
)
expect_equal(out, "rocker/verse:4.0")
})

9 changes: 4 additions & 5 deletions vignettes/dockerfile-from-renv-lock.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ knitr::opts_chunk$set(
library(dockerfiler)
```

<!-- This vignette is generated by fusen: do not edit by hand -->
<!-- WARNING - This vignette is generated by {fusen} from /dev/flat_dock_from_renv.Rmd: do not edit by hand -->

<!--
You need to run the 'description' chunk in the '0-dev_history.Rmd' file before continuing your code there.
Expand Down Expand Up @@ -47,12 +47,11 @@ renv::snapshot(
prompt = FALSE)

# Create Dockerfile
dock_from_renv(lockfile = the_lockfile,
my_dock <- dock_from_renv(lockfile = the_lockfile,
distro = "focal",
FROM = "rstudio/verse",
out_dir = dir_build
FROM = "rstudio/verse"
)

my_dock$write(file.path(dir_build, "Dockerfile"))
# rstudioapi::navigateToFile(file.path(dir_build, "Dockerfile"))
unlink(dir_build)
```
Expand Down