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

Build support for renv #20

Open
ColinFay opened this issue Sep 24, 2021 · 4 comments
Open

Build support for renv #20

ColinFay opened this issue Sep 24, 2021 · 4 comments

Comments

@ColinFay
Copy link
Member

Related issues : ThinkR-open/golem#656

@statnmap
Copy link
Member

As said here: ThinkR-open/golem#282 (comment)

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

  • a .dockerignore with renv and .Rprofile ignored as suggested by jcpsantiago :
.RData
.Rhistory
.git
.gitignore
manifest.json
rsconnect/
Rproj.user
.Rprofile
renv/
  • A Dockerfile like this that forces {renv} to use the classical path to install dependencies with renv::restore(library = .libPaths()):
    • Remember to create the dockerfile when you are in your package, with renv::status() up-to-date, so that currently installed versions are the same as in "renv.lock"
    • Note that sub-dependencies probably still don't have the correct version and will be re-installed by renv::restore()
    • Note also that when you change some code in your project, then renv::restore() will be called again as it appears after WORKDIR
FROM rocker/geospatial:4.0.1
RUN apt-get update && apt-get install -y  gdal-bin git-core libcairo2-dev libcurl4-openssl-dev libgdal-dev libgeos-dev libgeos++-dev libgit2-dev libicu-dev libpng-dev libpq-dev libproj-dev libssl-dev libudunits2-dev libxml2-dev make pandoc pandoc-citeproc zlib1g-dev && rm -rf /var/lib/apt/lists/*
RUN echo "options(repos = c(CRAN = 'https://packagemanager.rstudio.com/all/__linux__/focal/latest'), download.file.method = 'libcurl')" >> /usr/local/lib/R/etc/Rprofile.site
RUN echo "options(warn = 2);" >> $R_HOME/etc/Rprofile.site

# 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
Copy link
Member Author

Note: there is a WIP here #22

@statnmap
Copy link
Member

That should be good now.

@JosiahParry
Copy link
Contributor

Worth noting that this might be ready to be closed

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

No branches or pull requests

3 participants