diff --git a/DESCRIPTION b/DESCRIPTION index 9ba7bd6..b06e63b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: dockerfiler Title: Easy Dockerfile Creation from R -Version: 0.2.2.9002 +Version: 0.2.2.9003 Authors@R: c( person("Colin", "Fay", , "contact@colinfay.me", role = c("cre", "aut"), comment = c(ORCID = "0000-0001-7343-1846")), @@ -38,9 +38,8 @@ Suggests: rmarkdown (>= 2.6), testthat (>= 3.0.0), withr -VignetteBuilder: - knitr -Config/fusen/version: 0.5.2 +VignetteBuilder: knitr +Config/fusen/version: 0.6.0 Config/testthat/edition: 3 Encoding: UTF-8 LazyData: true diff --git a/NEWS.md b/NEWS.md index e35afa1..b521661 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,7 +2,7 @@ - remove sysreqs.r-hub.io to use {pak} instead for system requirement detection - move from `pak::pkg_system_requirements` to `pak::pkg_sysreqs()` thanks to @B0ydT - +- `dock_from_renv` allow to specify user to use in Dockerfile # dockerfile 0.2.2 diff --git a/R/dock_from_renv.R b/R/dock_from_renv.R index dd74421..e31190a 100644 --- a/R/dock_from_renv.R +++ b/R/dock_from_renv.R @@ -32,6 +32,7 @@ pkg_sysreqs_mem <- memoise::memoise( #' 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 +#' @param user Name of the user to specify in the Dockerfile with the USER instruction. Default is `NULL`, in which case the user from the FROM image is used. #' @importFrom utils getFromNamespace #' @return A R6 object of class `Dockerfile`. #' @details @@ -66,6 +67,7 @@ dock_from_renv <- function( expand = FALSE, extra_sysreqs = NULL, use_pak = FALSE, + user = NULL, renv_version ) { distro <- match.arg(distro, available_distros) @@ -83,7 +85,9 @@ dock_from_renv <- function( ), AS = AS ) - + if (!is.null(user)) { + dock$USER(user) + } # get renv version if (missing(renv_version)) { diff --git a/dev/config_attachment.yaml b/dev/config_attachment.yaml new file mode 100644 index 0000000..46e24ec --- /dev/null +++ b/dev/config_attachment.yaml @@ -0,0 +1,12 @@ +path.n: NAMESPACE +path.d: DESCRIPTION +dir.r: R +dir.v: vignettes +dir.t: tests +extra.suggests: ~ +pkg_ignore: ~ +document: yes +normalize: yes +inside_rmd: no +must.exist: yes +check_if_suggests_is_installed: yes diff --git a/dev/config_fusen.yaml b/dev/config_fusen.yaml index 49c242a..af07a3b 100644 --- a/dev/config_fusen.yaml +++ b/dev/config_fusen.yaml @@ -13,3 +13,4 @@ flat_dock_from_renv.Rmd: check: false document: false overwrite: 'yes' + clean: ask diff --git a/dev/flat_dock_from_renv.Rmd b/dev/flat_dock_from_renv.Rmd index b9673b6..efd2c33 100644 --- a/dev/flat_dock_from_renv.Rmd +++ b/dev/flat_dock_from_renv.Rmd @@ -75,6 +75,7 @@ pkg_sysreqs_mem <- memoise::memoise( #' 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 +#' @param user Name of the user to specify in the Dockerfile with the USER instruction. Default is `NULL`, in which case the user from the FROM image is used. #' @importFrom utils getFromNamespace #' @return A R6 object of class `Dockerfile`. #' @details @@ -104,6 +105,7 @@ dock_from_renv <- function( expand = FALSE, extra_sysreqs = NULL, use_pak = FALSE, + user = NULL, renv_version ) { distro <- match.arg(distro, available_distros) @@ -121,7 +123,9 @@ dock_from_renv <- function( ), AS = AS ) - + if (!is.null(user)) { + dock$USER(user) + } # get renv version if (missing(renv_version)) { diff --git a/man/dock_from_renv.Rd b/man/dock_from_renv.Rd index 5af0d40..d177359 100644 --- a/man/dock_from_renv.Rd +++ b/man/dock_from_renv.Rd @@ -14,6 +14,7 @@ dock_from_renv( expand = FALSE, extra_sysreqs = NULL, use_pak = FALSE, + user = NULL, renv_version ) } @@ -37,6 +38,8 @@ Will be installed with apt-get install.} \item{use_pak}{boolean. If \code{TRUE} use pak to deal with dependencies during \code{renv::restore()}. FALSE by default} +\item{user}{Name of the user to specify in the Dockerfile with the USER instruction. Default is \code{NULL}, in which case the user from the FROM image is used.} + \item{renv_version}{character. The renv version to use in the generated Dockerfile. By default, it is set to the version specified in the \code{renv.lock} file. If the \code{renv.lock} file does not specify a renv version, the version of renv bundled with dockerfiler, diff --git a/vignettes/dockerfile-from-renv-lock.Rmd b/vignettes/dockerfile-from-renv-lock.Rmd index 9eaa756..5063bfe 100644 --- a/vignettes/dockerfile-from-renv-lock.Rmd +++ b/vignettes/dockerfile-from-renv-lock.Rmd @@ -2,7 +2,7 @@ title: "Dockerfile from renv.lock" output: rmarkdown::html_vignette vignette: > - %\VignetteIndexEntry{dockerfile-from-renv-lock} + %\VignetteIndexEntry{Dockerfile from renv.lock} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- @@ -14,32 +14,28 @@ knitr::opts_chunk$set( ) ``` -```{r setup} +```{r} library(dockerfiler) ``` + + - # gen_base_image - - - # Create a Dockerfile from a renv.lock file - - ```{r example-dock_from_renv} #' \dontrun{ #' dock <- dock_from_renv("renv.lock", distro = "xenial") @@ -50,3 +46,4 @@ library(dockerfiler) +