Skip to content

Commit

Permalink
RC 2.2 (#67)
Browse files Browse the repository at this point in the history
version 2.2 on CRAN

* issue #66 set `renv.config.pak.enabled = FALSE`
* issue #64 
* issue #66
  • Loading branch information
VincentGuyader authored Nov 13, 2023
1 parent adcaaf1 commit 3fe2fd1
Show file tree
Hide file tree
Showing 13 changed files with 782 additions and 67 deletions.
5 changes: 3 additions & 2 deletions 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.1.9004
Version: 0.2.2
Authors@R: c(
person("Colin", "Fay", , "[email protected]", role = c("cre", "aut"),
comment = c(ORCID = "0000-0001-7343-1846")),
Expand Down Expand Up @@ -37,8 +37,9 @@ Suggests:
testthat (>= 3.0.0),
withr
VignetteBuilder: knitr
Config/fusen/version: 0.5.2.9000
Config/fusen/version: 0.5.1
Config/testthat/edition: 3
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.2.3
Roxygen: list(markdown = TRUE)
4 changes: 3 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# dockerfile 0.2.x to 0.3.0
# dockerfile 0.2.2

- fix : create a `use_pak` parameters in `dock_from_renv` to set `renv.config.pak.enabled = FALSE` instead of `renv.config.pak.enabled = TRUE` to avoid issues with {pak} during `renv::restore()`

- feat: use of {memoise} to cache call to `pak::pkg_system_requirements`

Expand Down
27 changes: 14 additions & 13 deletions R/dock_from_renv.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,26 @@ pkg_system_requirements_mem <- memoise::memoise(
#' Create a Dockerfile from an `renv.lock` file
#'
#' @param lockfile Path to an `renv.lock` file to use as an input..
#' @param FROM Docker image to start FROM Default is
#' FROM rocker/r-base
#' @param AS The AS of the Dockerfile. Default it NULL.
#' @param distro One of "focal", "bionic", "xenial", "centos7",
#' or "centos8". See available distributions
#' at https://hub.docker.com/r/rstudio/r-base/.
#' @param sysreqs boolean. If `TRUE`, the Dockerfile
#' will contain sysreq installation.
#' @param FROM Docker image to start FROM Default is FROM rocker/r-base
#' @param AS The AS of the Dockerfile. Default it `NULL`.
#' @param distro One of "focal", "bionic", "xenial", "centos7",or "centos8". See available distributions at https://hub.docker.com/r/rstudio/r-base/.
#' @param sysreqs boolean. If `TRUE`, the Dockerfile will contain sysreq installation.
#' @param expand boolean. If `TRUE` each system requirement will have its own `RUN` line.
#' @param repos character. The URL(s) of the repositories to use for `options("repos")`.
#' @param extra_sysreqs character vector. Extra debian system requirements.
#' Will be installed with apt-get install.
#' @param renv_version character. The {renv} version to use in the generated Dockerfile.
#' By default, it is set to the version specified in the `renv.lock` file.
#' If the `renv.lock` file does not specify a {renv} version, the version of {renv} bundled with {dockerfiler}, specifically `dockerfiler::renv$the$metadata$version`, will be used. If you set it to NULL, the latest available version of {renv} will be used.
#' @param renv_version character. The renv version to use in the generated Dockerfile. By default, it is set to the version specified in the `renv.lock` file.
#' If the `renv.lock` file does not specify a renv version,
#' the version of renv bundled with dockerfiler,
#' specifically `r dockerfiler::renv$initialize();toString(dockerfiler::renv$the$metadata$version)`, will be used.
#' If you set it to `NULL`, the latest available version of renv will be used.
#' @param use_pak boolean. If `TRUE` use pak to deal with dependencies during `renv::restore()`. FALSE by default
#' @importFrom utils getFromNamespace
#' @return A R6 object of class `Dockerfile`.
#' @details
#'
#' System requirements for packages are provided
#' through RStudio Package Manager via the {pak}
#' through RStudio Package Manager via the pak
#' package. The install commands provided from pak
#' are added as `RUN` directives within the `Dockerfile`.
#'
Expand All @@ -65,6 +64,7 @@ dock_from_renv <- function(
repos = c(CRAN = "https://cran.rstudio.com/"),
expand = FALSE,
extra_sysreqs = NULL,
use_pak = FALSE,
renv_version
) {
distro <- match.arg(distro, available_distros)
Expand Down Expand Up @@ -256,7 +256,8 @@ dock_from_renv <- function(

dock$RUN(
sprintf(
"echo \"options(renv.config.pak.enabled = TRUE, repos = %s, download.file.method = 'libcurl', Ncpus = 4)\" | tee /usr/local/lib/R/etc/Rprofile.site | tee /usr/lib/R/etc/Rprofile.site",
"echo \"options(renv.config.pak.enabled = %s, repos = %s, download.file.method = 'libcurl', Ncpus = 4)\" | tee /usr/local/lib/R/etc/Rprofile.site | tee /usr/lib/R/etc/Rprofile.site",
use_pak,
repos_as_character
)
)
Expand Down
3 changes: 1 addition & 2 deletions R/renv.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
#


#' Internalised {renv}
#' Internalised renv
#'
#' https://rstudio.github.io/renv/reference/vendor.html?q=vendor
#'
#' @export
#' @name renv
#' @alias renv
#' @docType data
renv <- new.env(parent = new.env())

Expand Down
38 changes: 23 additions & 15 deletions dev/flat_dock_from_renv.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -61,27 +61,26 @@ pkg_system_requirements_mem <- memoise::memoise(
#' Create a Dockerfile from an `renv.lock` file
#'
#' @param lockfile Path to an `renv.lock` file to use as an input..
#' @param FROM Docker image to start FROM Default is
#' FROM rocker/r-base
#' @param AS The AS of the Dockerfile. Default it NULL.
#' @param distro One of "focal", "bionic", "xenial", "centos7",
#' or "centos8". See available distributions
#' at https://hub.docker.com/r/rstudio/r-base/.
#' @param sysreqs boolean. If `TRUE`, the Dockerfile
#' will contain sysreq installation.
#' @param FROM Docker image to start FROM Default is FROM rocker/r-base
#' @param AS The AS of the Dockerfile. Default it `NULL`.
#' @param distro One of "focal", "bionic", "xenial", "centos7",or "centos8". See available distributions at https://hub.docker.com/r/rstudio/r-base/.
#' @param sysreqs boolean. If `TRUE`, the Dockerfile will contain sysreq installation.
#' @param expand boolean. If `TRUE` each system requirement will have its own `RUN` line.
#' @param repos character. The URL(s) of the repositories to use for `options("repos")`.
#' @param extra_sysreqs character vector. Extra debian system requirements.
#' Will be installed with apt-get install.
#' @param renv_version character. The {renv} version to use in the generated Dockerfile.
#' By default, it is set to the version specified in the `renv.lock` file.
#' If the `renv.lock` file does not specify a {renv} version, the version of {renv} bundled with {dockerfiler}, specifically `dockerfiler::renv$the$metadata$version`, will be used. If you set it to NULL, the latest available version of {renv} will be used.
#' @param renv_version character. The renv version to use in the generated Dockerfile. By default, it is set to the version specified in the `renv.lock` file.
#' If the `renv.lock` file does not specify a renv version,
#' the version of renv bundled with dockerfiler,
#' specifically `r dockerfiler::renv$initialize();toString(dockerfiler::renv$the$metadata$version)`, will be used.
#' If you set it to `NULL`, the latest available version of renv will be used.
#' @param use_pak boolean. If `TRUE` use pak to deal with dependencies during `renv::restore()`. FALSE by default
#' @importFrom utils getFromNamespace
#' @return A R6 object of class `Dockerfile`.
#' @details
#'
#' System requirements for packages are provided
#' through RStudio Package Manager via the {pak}
#' through RStudio Package Manager via the pak
#' package. The install commands provided from pak
#' are added as `RUN` directives within the `Dockerfile`.
#'
Expand All @@ -103,6 +102,7 @@ dock_from_renv <- function(
repos = c(CRAN = "https://cran.rstudio.com/"),
expand = FALSE,
extra_sysreqs = NULL,
use_pak = FALSE,
renv_version
) {
distro <- match.arg(distro, available_distros)
Expand Down Expand Up @@ -294,7 +294,8 @@ dock_from_renv <- function(
dock$RUN(
sprintf(
"echo \"options(renv.config.pak.enabled = TRUE, repos = %s, download.file.method = 'libcurl', Ncpus = 4)\" | tee /usr/local/lib/R/etc/Rprofile.site | tee /usr/lib/R/etc/Rprofile.site",
"echo \"options(renv.config.pak.enabled = %s, repos = %s, download.file.method = 'libcurl', Ncpus = 4)\" | tee /usr/local/lib/R/etc/Rprofile.site | tee /usr/lib/R/etc/Rprofile.site",
use_pak,
repos_as_character
)
)
Expand Down Expand Up @@ -349,11 +350,14 @@ custom_packages <- c(
"knitr"
)
try(dockerfiler::renv$initialize(),silent=TRUE)
if ( !testthat:::on_cran()){
dockerfiler::renv$snapshot(
packages = custom_packages,
lockfile = the_lockfile,
prompt = FALSE
)
) } else {
file.copy(from = system.file("renv.lock",package = "dockerfiler"),to = the_lockfile)
}
# Modify R version for tests
renv_file <- readLines(file.path(dir_build, "renv.lock"))
Expand All @@ -364,6 +368,7 @@ writeLines(renv_file, file.path(dir_build, "renv.lock"))
# dock_from_renv ----
test_that("dock_from_renv works", {
# testthat::skip_on_cran()
# skip_if_not(interactive())
# Create Dockerfile
Expand Down Expand Up @@ -472,7 +477,7 @@ test_that("gen_base_image works", {
test_that("dock_from_renv works with specific renv", {
# testthat::skip_on_cran()
the_lockfile1.0.0 <- system.file("renv_with_1.0.0.lock",package = "dockerfiler")
for (lf in list(the_lockfile,the_lockfile1.0.0)){
Expand Down Expand Up @@ -533,4 +538,7 @@ fusen::inflate(flat_file = "dev/flat_dock_from_renv.Rmd", vignette_name = "Docke
document = FALSE
# ,pkg_ignore = "renv"
)
# attention si la version de renv vendor change il faut éditer la doc
```
Loading

0 comments on commit 3fe2fd1

Please sign in to comment.