Skip to content
Open
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
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: dockerfiler
Title: Easy Dockerfile Creation from R
Version: 0.2.5
Version: 0.2.5.9001
Authors@R: c(
person("Colin", "Fay", , "[email protected]", role = c("cre", "aut"),
comment = c(ORCID = "0000-0001-7343-1846")),
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# dockerfiler dev version

- feat: In dock_from_renv, introduce build-arg RENV_PATHS_CACHE (default /root/.cache/R/renv) and propagate it as an ENV variable for configurable renv cache paths.
- feat: In dock_from_renv, update cache mounting to --mount=type=cache,id=renv-cache,target=${RENV_PATHS_CACHE} and use renv::restore(clean=FALSE) to speed up and harden the Docker build.

# dockerfiler 0.2.5

- feat: allow multistage dockerfile creation
Expand Down
6 changes: 5 additions & 1 deletion R/dock_from_renv.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ dock_from_renv <- function(
),
AS = AS
)
dock$ARG("RENV_PATHS_CACHE=/root/.cache/R/renv")
dock$ENV(key = "RENV_PATHS_CACHE",value = "${RENV_PATHS_CACHE}")

if (!is.null(user)) {
dock$USER(user)
}
Expand Down Expand Up @@ -240,7 +243,8 @@ dock_from_renv <- function(
}

dock$COPY(basename(lockfile), "renv.lock")
dock$RUN("--mount=type=cache,id=renv-cache,target=/root/.cache/R/renv R -e 'renv::restore()'")
dock$RUN("--mount=type=cache,id=renv-cache,target=${RENV_PATHS_CACHE} R -e 'renv::restore(clean = FALSE)'")

dock
}

1 change: 1 addition & 0 deletions dockerfiler.Rproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Version: 1.0
ProjectId: aea0fc85-ff2f-4b78-a34d-39f668860543

RestoreWorkspace: No
SaveWorkspace: No
Expand Down
7 changes: 0 additions & 7 deletions tests/testthat/Dockerfile

This file was deleted.

4 changes: 3 additions & 1 deletion tests/testthat/renv_Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
FROM rocker/verse:4.1.2
ARG RENV_PATHS_CACHE=/root/.cache/R/renv
ENV "RENV_PATHS_CACHE"="${RENV_PATHS_CACHE}"
RUN fake sys reqs
RUN mkdir -p /usr/local/lib/R/etc/ /usr/lib/R/etc/
RUN echo "options(renv.config.pak.enabled = FALSE, repos = fake repos, download.file.method = 'libcurl', Ncpus = 4)" | tee /usr/local/lib/R/etc/Rprofile.site | tee /usr/lib/R/etc/Rprofile.site
RUN R -e 'install.packages("remotes")'
RUN R -e 'remotes::install_version("renv", version = "0.0.0")'
COPY renv.lock renv.lock
RUN --mount=type=cache,id=renv-cache,target=/root/.cache/R/renv R -e 'renv::restore()'
RUN --mount=type=cache,id=renv-cache,target=${RENV_PATHS_CACHE} R -e 'renv::restore(clean = FALSE)'