jsta / r-docker-tutorial

A docker tutorial for reproducible research
http://jsta.github.io/r-docker-tutorial
250 stars 94 forks source link

Consider use of littler `install2.r` scripts in the "Writing Dockerfiles" docs? #41

Open cboettig opened 7 years ago

cboettig commented 7 years ago

install2.r just provides a more concise syntax for adding R packages in Dockerfiles, it's available on all rocker images since we use it in the Rocker Dockerfiles too. One can just do:

RUN install2.r -e  bookdown rticles rmdshower

to install those packages.

Note that the repo is set by default (rstudio CRAN mirror on :latest, versioned images instead pull from the MRAN snapshots by default to ensure reproducibility).

The -e flag is optional, it makes install.packages() throw an error if the package installation fails (which will cause the docker build command to fail). By default, install.packages() only throws a warning, which means that a Dockerfile can build successfully even if it has failed to install the package.

samvaltenbergs commented 6 years ago

@cboettig we have had some changes to the firewalls and it's preventing Docker from establishing an SSL with the sites for downloading some of our packages via install2r.

I have tried passing in an environment variable to the R session in the Docker file as follows, but the R session doesn't seem to be picking it up:

RUN R -e "Sys.setenv(https_proxy = 'https://XXX.XXX.COM')" \ && install2.r \ --error \ --deps FALSE \ data.table

I have also tried putting the following at the top of the Docker file in question, but that doesn't seem to work either:

ENV HTTPS_PROXY "https://XXX.XXX.COM"

Do you have any suggestions as to how I can get the R packages in install2.r to install using a proxy? Thanks for your help...

cboettig commented 6 years ago

shooting from the hip here, but is not using the https url an option? e.g. install2.r -r http://cran.rstudio.com data.table ?

I'm not familiar with using https_proxy like this, but do you have this working as a pure R script instead of the install2.r way?

samvaltenbergs commented 6 years ago

@cboettig thanks for the response. With some help from Docker support and the network engineers, we've isolated the issue to some changes on our proxy server that aren't allowing curl to establish SSL connections. wget however, works okay inside a Docker container as long as one tells wget to use a proxy. So I think I need to try using a proxy - possibly using Sys.setenv(https_proxy = 'https://XXX.XXX.COM') - as well as telling install.packages() to use wget instead of the auto method that it defaults to.

I was looking over the documentation/code for install2.r and it doesn't look like there's an option to specify the method that install.packages() will use. Is that the case? If so, do you have another suggestion for installing packages in the Rocker image while being able to specify the method of install.packages()?

cboettig commented 6 years ago

yeah, install2.r is really just a wrapper to make common patterns less writing. Recall that you can always just call install.packages() directly in your docker file, e.g.

RUN R -e "install.packages('httr', method='wget')"

etc

samvaltenbergs commented 6 years ago

Yup, can do, I just like the cleanliness of install2.r. Thanks VM for your quick responses!