1

This is the first time I'm using Docker. I have tried a few times but this is the first time where I'm containerizing the project. The project generates reports using latex and officer. However, after building the container and running the image, Rstudio shows that none of the packages are installed and loaded.

Dockerfile

FROM rocker/verse:4.0.5

ENV RENV_VERSION 0.15.1
RUN R -e "install.packages('remotes', repos = c(CRAN = 'https://cloud.r-project.org'))"
RUN R -e "remotes::install_github('rstudio/renv@${RENV_VERSION}')"

WORKDIR /REAL
COPY . .
RUN apt-get -y update --fix-missing
#RUN apt-get -y install build-essential \
#   libssl-dev \
#   libcurl4-openssl-dev \
#   libxml2-dev \
#   libfontconfig1-dev \
#   libcairo2-dev
RUN R -e 'options(renv.consent = TRUE); renv::restore(lockfile = "/REAL/renv.lock"); renv::activate()'

Building Docker image

docker build -t reports/real . 

Running docker with rstudio support

docker run --rm -d -p 8787:8787 --name real_report -e ROOT=TRUE -e DISABLE_AUTH=TRUE -v C:/Users/test/sources/REAL_Reports:/home/rstudio/REAL_Reports reports/real:latest

What am I doing wrong and how do I fix it so that all packages that renv has discovered are installed and loaded?

camille
  • 16,432
  • 18
  • 38
  • 60
Kuni
  • 817
  • 1
  • 9
  • 24

1 Answers1

2

RUN R -e 'options(renv.consent = TRUE); renv::restore(lockfile = "/REAL/renv.lock"); renv::activate()'

You likely need to activate / load your project before calling restore(), or just forego using a project-local library altogether.

https://rstudio.github.io/renv/articles/docker.html may also be useful here.

Kevin Ushey
  • 20,530
  • 5
  • 56
  • 88