This is my Dockerfile for my shiny app: FROM rocker/shiny:4.4.1 ENV…
- User
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
This is my Dockerfile for my shiny app:
FROM rocker/shiny:4.4.1
ENV RENV_CONFIG_RSPM_ENABLED=TRUE
ENV RENV_CONFIG_REPOS_OVERRIDE=https://packagemanager.posit.co/cran/__linux__/noble/latest
RUN apt-get update -qq && \
apt-get install -y --no-install-recommends \
libcurl4-openssl-dev \
libfontconfig1-dev \
libfreetype6-dev \
libfribidi-dev \
libglpk-dev \
libharfbuzz-dev \
libicu-dev \
libjpeg-dev \
libpng-dev \
libssl-dev \
libtiff-dev \
libx11-dev \
libxml2-dev \
make \
pandoc \
curl \
zlib1g-dev && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
COPY shiny_renv.lock renv.lock
RUN Rscript -e "install.packages('renv', repos = c(CRAN = 'https://cloud.r-project.org'))"
RUN Rscript -e "renv::restore()"
COPY shiny_app /srv/shiny-server/
EXPOSE 3838
CMD ["/usr/bin/shiny-server"]
When I try to build it, I get the following error:
docker build -t $IMAGE_TAG -f shiny_app/Dockerfile .
[+] Building 56.7s (9/10) docker:default
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 947B 0.0s
=> [internal] load metadata for docker.io/rocker/shiny:4.4.1 1.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> CACHED [1/6] FROM docker.io/rocker/shiny:4.4.1@sha256:c50810df4747090eceb2f94da767ad27ad92dc78f96440577cfb8dbe46431026 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 13.19kB 0.0s
=> [2/6] RUN apt-get update -qq && apt-get install -y --no-install-recommends libcurl4-openssl-dev libfontconfig1-dev libfreetype6-dev libfribidi-dev libglpk-dev libharfbu 52.2s
=> [3/6] COPY shiny_renv.lock renv.lock 0.0s
=> [4/6] RUN Rscript -e "install.packages('renv', repos = c(CRAN = 'https://cloud.r-project.org'))" 2.5s
=> ERROR [5/6] RUN Rscript -e "renv::restore()" 0.9s
> [5/6] RUN Rscript -e "renv::restore()":
0.892 Error in loadNamespace(x) : there is no package called ‘renv’
0.892 Calls: loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
0.892 Execution halted
1 warning found (use docker --debug to expand):
- LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format (line 4)
Dockerfile:28
26 | COPY shiny_renv.lock renv.lock
27 | RUN Rscript -e "install.packages('renv', repos = c(CRAN = 'https://cloud.r-project.org'))"
28 | >>> RUN Rscript -e "renv::restore()"
29 | COPY shiny_app /srv/shiny-server/
30 | EXPOSE 3838
ERROR: failed to solve: process "/bin/sh -c Rscript -e "renv::restore()"" did not complete successfully: exit code: 1
The error message indicates that the renv package is not found when attempting to run renv::restore(). This suggests that the renv package might not have been installed correctly in the previous step.
Here's a revised Dockerfile to ensure that renv is installed correctly before attempting to restore the project dependencies:
FROM rocker/shiny:4.4.1
ENV RENV_CONFIG_RSPM_ENABLED=TRUE
ENV RENV_CONFIG_REPOS_OVERRIDE=https://packagemanager.posit.co/cran/__linux__/noble/latest
RUN apt-get update -qq && \
apt-get install -y --no-install-recommends \
libcurl4-openssl-dev \
libfontconfig1-dev \
libfreetype6-dev \
libfribidi-dev \
libglpk-dev \
libharfbuzz-dev \
libicu-dev \
libjpeg-dev \
libpng-dev \
libssl-dev \
libtiff-dev \
libx11-dev \
libxml2-dev \
make \
pandoc \
curl \
zlib1g-dev && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
COPY shiny_renv.lock renv.lock
# Ensure renv is installed
RUN R -e "install.packages('renv', repos = c(CRAN = 'https://cloud.r-project.org'), dependencies = TRUE)"
# Initialize renv and restore dependencies
RUN Rscript -e "renv::init(bare = TRUE)" && \
Rscript -e "renv::restore()"
COPY shiny_app /srv/shiny-server/
EXPOSE 3838
CMD ["/usr/bin/shiny-server"]
Install renv with dependencies:
install.packages command now includes dependencies = TRUE to ensure all dependencies of renv are installed.Initialize renv:
renv::init(bare = TRUE) is called to initialize renv in the project. This step ensures that renv is set up correctly before attempting to restore the dependencies.These changes should help ensure that renv is properly installed and initialized before attempting to restore the project dependencies, thereby resolving the error you encountered.