Skip to content

Commit cdd3ba0

Browse files
author
Susan Vanderplas
committed
Try specifying cache directories differently
1 parent 65bae97 commit cdd3ba0

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

Dockerfile

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
# At the top
2-
ARG RENV_CACHE=/root/.cache/R/renv/
3-
ARG PIP_CACHE=/root/.cache/pip
4-
51
# Base image
62
FROM rocker/verse:latest
73

84
# Set environment variables so renv/pip use them
9-
ENV R_CACHE_DIR=/root/.cache/R/
10-
ENV RENV_PATHS_CACHE=${RENV_CACHE}
11-
ENV PIP_CACHE_DIR=${PIP_CACHE}
5+
ENV R_CACHE=/root/.cache/R/
6+
ENV RENV_CACHE=/root/.cache/R/renv/
7+
ENV PIP_CACHE=/root/.cache/pip
128

139
# Install Python
1410
RUN apt-get update && apt-get install -y \
@@ -53,22 +49,22 @@ ENV DEBIAN_FRONTEND=noninteractive
5349
# RUN mkdir -p ${RENV_CACHE} ${PIP_CACHE}
5450

5551
# Install tinytex system-wide (for LaTeX support)
56-
RUN --mount=type=cache,target=${R_CACHE_DIR} Rscript -e "install.packages('tinytex'); tinytex::install_tinytex(force=T)"
52+
RUN --mount=type=cache,target=${R_CACHE} Rscript -e "install.packages('tinytex'); tinytex::install_tinytex(force=T)"
5753

5854
# Install minimal R packages for system-level support
59-
RUN --mount=type=cache,target=${R_CACHE_DIR} Rscript -e "install.packages(c('digest','devtools','renv','reticulate','yaml'))"
55+
RUN --mount=type=cache,target=${R_CACHE} Rscript -e "install.packages(c('digest','devtools','renv','reticulate','yaml'))"
6056

6157
# Copy renv.lock and renv directory for layer caching, install R dependencies via renv
6258
COPY renv.lock /project/renv.lock
6359
COPY renv /project/renv
6460

6561
# Restore R deps from renv.lock using persistent cache
66-
RUN --mount=type=cache,target=${R_CACHE_DIR} Rscript -e 'renv::restore(lockfile = '/project/renv.lock', prompt = FALSE)'
62+
RUN --mount=type=cache,target=${R_CACHE} Rscript -e 'renv::restore(lockfile = '/project/renv.lock', prompt = FALSE)'
6763

6864
# Copy Python requirements file if exists (cached separately)
6965
COPY setup/requirements.txt ${REQ_FILE}
70-
RUN --mount=type=cache,target=${PIP_CACHE_DIR} python3 -m venv /root/.virtualenvs/venv && \
71-
"${VENV_PATH}/bin/pip" install --cache-dir "${PIP_CACHE_DIR}" -r "${REQ_FILE}"
66+
RUN --mount=type=cache,target=${PIP_CACHE} python3 -m venv /root/.virtualenvs/venv && \
67+
"${VENV_PATH}/bin/pip" install --cache-dir "${PIP_CACHE}" -r "${REQ_FILE}"
7268

7369
# Copy the rest of the project
7470
COPY . /project

0 commit comments

Comments
 (0)