ThinkR-open / dockerfiler

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

Build support for renv #20

Open ColinFay opened 2 years ago

ColinFay commented 2 years ago

Related issues : https://github.com/ThinkR-open/golem/issues/656

statnmap commented 2 years ago

As said here: https://github.com/ThinkR-open/golem/issues/282#issuecomment-891118964

A new test today with a combination of {renv} and Docker cache requires:

Dependencies as extracted from DESCRIPTION file as usual

RUN Rscript -e 'install.packages("remotes")' RUN Rscript -e 'remotes::install_version("stringr",upgrade="never", version = "1.4.0")' RUN Rscript -e 'remotes::install_version("glue",upgrade="never", version = "1.4.2")' RUN Rscript -e 'remotes::install_version("magrittr",upgrade="never", version = "2.0.1")' RUN Rscript -e 'remotes::install_version("future",upgrade="never", version = "1.21.0")' RUN Rscript -e 'remotes::install_version("cartography",upgrade="never", version = "2.4.2")' RUN Rscript -e 'remotes::install_github("Thinkr-open/golem@aaae5c8788802a7b4aef4df23691902a286dd964")'

renv part

RUN Rscript -e 'remotes::install_github("rstudio/renv")' RUN mkdir /build_zone ADD . /build_zone WORKDIR /build_zone

RUN Rscript -e 'source("renv/activate.R")'

Still need to restore in case sub-dependencies versions are not good

RUN Rscript -e 'renv::restore(library = .libPaths())' RUN Rscript -e 'remotes::install_local(upgrade = FALSE)' RUN rm -rf /build_zone

Remove option to warn and stop

RUN head -n -1 $R_HOME/etc/Rprofile.site

RUN echo "options(warn = -1);" >> $R_HOME/etc/Rprofile.site

EXPOSE 3838 CMD ["R", "-e", "options('shiny.port'=3838,shiny.host='0.0.0.0');mygolem::run_app()"]

ColinFay commented 2 years ago

Note: there is a WIP here https://github.com/ColinFay/dockerfiler/pull/22

statnmap commented 2 years ago

That should be good now.

JosiahParry commented 2 years ago

Worth noting that this might be ready to be closed