nanxstats / liftr

🐳 Containerize R Markdown documents for continuous reproducibility
https://nanx.me/liftr/
GNU General Public License v3.0
170 stars 20 forks source link

Need to be able to replace arguments like `-u` using run_arg in `render_docker()` #38

Closed stephlocke closed 6 years ago

stephlocke commented 6 years ago

Feature Request

When someone provides values to run_args it will remove any default args that render_docker() may have included.

Background

Docker is a wonderful thing 😂 I'm using Docker for Windows and it's probably the reason my docker containers don't contain the env var $USER. As such, render_docker() fails. I tried working around this by using the predefined user name root based on running whoami in containers.

Repro

library(liftr)
path = paste0("T://liftr-tidyverse/")
dir.create(path)
file.copy(system.file("examples/liftr-tidyverse.Rmd", package = "liftr"), path)
input = paste0(path, "liftr-tidyverse.Rmd")
lift(input)
render_docker(input,run_args = "-u 0")
$docker_run_cmd
[1] "docker run --rm -u 0 --name \"liftr_container_3b0c9c71_9285_4734_bfd0_9fae65750526\" -u `id -u $USER` -v \"T:/liftr-tidyverse:/liftrroot/\" liftr-tidyverse Rscript -e \"library('knitr');library('rmarkdown');library('shiny');setwd('/liftrroot/');render(input = 'liftr-tidyverse.Rmd')\""

Unfortunately, this gets added but so does the existing argument flag and values that you provide by default.

nanxstats commented 6 years ago

@stephlocke - thanks for reporting the issue. It seems legit, though the purpose of run_arg is merely for specifying additional docker run arguments, instead of replacing all of them.

I guess a more proper solution could be setting the environment variable $USER in the Dockerfile. You can include any of such snippets by using the metadata include when you use liftr::lift() to generate the Dockerfile.

stephlocke commented 6 years ago

Good idea!