ThinkR-open / dockerfiler

Easy Dockerfile Creation from R
https://thinkr-open.github.io/dockerfiler/
Other
176 stars 27 forks source link

`FROM` overwrites options from `distro` making broken Dockerfiles #58

Open JosiahParry opened 1 year ago

JosiahParry commented 1 year ago

The default FROM argument is rocker/r-base which is a debian image. Using the distro arg helps find the appropriate system dependencies. the FROM argument will always be rocker/r-base for all distro values.

For example a simple renv.lock file with the following call

dock <- dockerfiler::dock_from_renv(distro = "centos8")
dock$write()

Generated this dockerfile

FROM rocker/r-base:4.3.0
RUN yum update -y && dnf install -y libcurl-devel
RUN dnf install -y openssl-devel
# ......truncated for brevity.....
RUN mkdir -p /usr/local/lib/R/etc/ /usr/lib/R/etc/
RUN echo "options(renv.config.pak.enabled = TRUE, repos = c(CRAN = 'https://cran.rstudio.com/'), download.file.method = 'libcurl', Ncpus = 4)" | tee /usr/local/lib/R/etc/Rprofile.site | tee /usr/lib/R/etc/Rprofile.site
RUN R -e 'install.packages(c("renv","remotes"))'
COPY renv.lock renv.lock
RUN R -e 'renv::restore()'

If pak is to be used for identifying system dependencies, I believe the FROM argument should be removed and the FROM statement derived from the distro argument so that the base image and the system dep commands are in agreement.

https://github.com/ThinkR-open/dockerfiler/blob/e40f804e9728afb9bb5a8c52d965c9ac4a8fd58a/R/dock_from_renv.R#L50

VincentGuyader commented 11 months ago

I totaly agree :)

VincentGuyader commented 5 months ago

In fact, it's rather complicated to manage several different OS for the Docker image. The interest is very minimal. Here we should go back to rstudio/r-base... but it seems unnecessary to me. Let's simplify all this. Always start from rocker/r-base, which is based on Debian. And that will be more than enough :)

VincentGuyader commented 5 months ago

Either the user defines a FROM, and we'll use exactly the image passed as a parameter, or we'll use r_version/ the R from the renv.lock to use the base version of rocker/r-base. This will also help manage bug #53