Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docker #126

Open
moldach opened this issue Mar 3, 2019 · 8 comments
Open

Add docker #126

moldach opened this issue Mar 3, 2019 · 8 comments

Comments

@moldach
Copy link
Contributor

moldach commented Mar 3, 2019

The benmarwick/rrtools package has a function (rrtools::use_dockerfile) which creates a dockerfile along with a project template. I'm wondering if a similar function for starters would be desired as a function argument (e.g. docker = FALSE)?

If so, I'd like to take a crack at it

@stephlocke
Copy link
Member

That sounds great!
I think you could initially do a very simple template with rocker/r-base as a starter Dockerfile. Bonus points if you use the whoami integration to write the maintainer info into the file.

@maelle
Copy link
Contributor

maelle commented Apr 1, 2019

👋 @moldach! Still interested in a PR? :-)

@moldach
Copy link
Contributor Author

moldach commented Apr 1, 2019

👋 @moldach! Still interested in a PR? :-)

Hi @maelle I actually just started looking into this last night and had a few questions before I descend too far into the Rabbit hole.

My thinking is that this feature should be added to external_setup.R (between lines 47-71) as an option for the setup_repo function (i,e, ci_activation = c( "travis", "travis-with-docker")).

The second question is:

Bonus points if you use the whoami integration to write the maintainer info into the file.

I know the containerit package was designed to automagically generate a suitable Dockerfile; if we are not too worried about including another dependency I could integrate this. Alternatively, what about a system call to docker pull r-base and then some string manipulation to edit maintainer info with gh::gh_whoami?

@maelle
Copy link
Contributor

maelle commented Apr 1, 2019

I'd actually view this as an alternative packagedeps option?

Yes starters could use containerit, starters is not meant to be light weight. A system call sounds a bit fragile. Do you know how containerit finds info about the maintainer?

@moldach
Copy link
Contributor Author

moldach commented Apr 7, 2019

Okay I spent quite a bit of time learning about Docker/Rocker the past few days; making docker image and creating containers and looking into containerit. containerit finds out info about the maintainer via Sys.info()[["user"]]. I believe starters is using whoami::username() which calls Sys.getenv()[["USERNAME"]] - they look the same to me. If not we can change the maintainer with an arugment to dockerfile(): i.e. labeled_dockerfile <- dockerfile(from = clean_session(), maintainer = whoami::username()`

Concerning the creation of the Dockerfile, containerit::dockerfile() uses sessionInfo() to create a dockerfile_object that can be used to build a Docker image. I ran through the steps for createPackageProject and, after git_add_infrastructure(), ran containerit::dockerfile() and this is what the dockerfile would look like:

dockerfile_object
An object of class "Dockerfile"
Slot "image":
An object of class "From"
Slot "image":
[1] "rocker/r-ver"

Slot "postfix":
An object of class "Tag"
[1] "3.5.3"


Slot "maintainer":
An object of class "Label"
Slot "data":
$maintainer
[1] "Matthew"


Slot "multi_line":
[1] FALSE


Slot "instructions":
[[1]]
An object of class "Run_shell"
Slot "commands":
[1] "export DEBIAN_FRONTEND=noninteractive; apt-get -y update"                       
[2] "apt-get install -y git-core \\\n\tlibcurl4-openssl-dev \\\n\tlibssl-dev \\\n\tmake"


[[2]]
An object of class "Run"
Slot "exec":
[1] "install2.r"

Slot "params":
 [1] "assertthat"     "backports"      "callr"          "cli"            "crayon"         "curl"           "desc"           "devtools"      
 [9] "digest"         "formatR"        "fs"             "futile.logger"  "futile.options" "glue"           "lambda.r"       "magrittr"      
[17] "packrat"        "pkgbuild"       "pkgload"        "prettyunits"    "processx"       "ps"             "R6"             "Rcpp"          
[25] "remotes"        "rlang"          "rprojroot"      "rstudioapi"     "semver"         "sessioninfo"    "stevedore"      "stringi"       
[33] "stringr"        "testthat"       "usethis"        "withr"         


[[3]]
An object of class "Run"
Slot "exec":
[1] "installGithub.r"

Slot "params":
[1] "hadley/memoise@1650ad7f9c27d2e0a932e50b16eedb574e8050df"


[[4]]
An object of class "Workdir"
Slot "path":
[1] "/payload/"



Slot "entrypoint":
NULL

Slot "cmd":
An object of class "Cmd"
Slot "exec":
[1] "R"

Slot "params":
[1] NA

Slot "form":
[1] "exec"

Excuse my ignorance about alternative packagedeps - I googled a bit but couldn't find out much. I think the build_vignettes paramater from devtools::install_github("auth/repo", build_vignettes=TRUE) is a sort of conditional installation but I'm not having much look figuring out how that's done. I would appreciate it if you could you point me to any literature on the matter?

@maelle
Copy link
Contributor

maelle commented Apr 8, 2019

I believe starters is using whoami::username() which calls Sys.getenv()[["USERNAME"]] - they look the same to me. If not we can change the maintainer with an argument to dockerfile()

They give the same output for me too but I wonder whether one of them is more robust? I'll try to get some information about that.

I do not understand your question about alternative packagedeps?

@moldach
Copy link
Contributor Author

moldach commented Apr 8, 2019

I do not understand your question about alternative packagedeps?

When you say alternative package dependencies I thought you meant an install command which would include containerit as a dependency if TRUE or not be included as a dependency if set to FALSE (much like vignettes are either included (or withheld) from install_github()). Perhaps you mean something else?

@maelle
Copy link
Contributor

maelle commented Apr 9, 2019

cc @stephlocke

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants