|
1 | | -# At the top |
2 | | -ARG RENV_CACHE=/root/.cache/R/renv/ |
3 | | -ARG PIP_CACHE=/root/.cache/pip |
4 | | - |
5 | 1 | # Base image |
6 | 2 | FROM rocker/verse:latest |
7 | 3 |
|
8 | 4 | # 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 |
12 | 8 |
|
13 | 9 | # Install Python |
14 | 10 | RUN apt-get update && apt-get install -y \ |
@@ -53,22 +49,22 @@ ENV DEBIAN_FRONTEND=noninteractive |
53 | 49 | # RUN mkdir -p ${RENV_CACHE} ${PIP_CACHE} |
54 | 50 |
|
55 | 51 | # 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)" |
57 | 53 |
|
58 | 54 | # 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'))" |
60 | 56 |
|
61 | 57 | # Copy renv.lock and renv directory for layer caching, install R dependencies via renv |
62 | 58 | COPY renv.lock /project/renv.lock |
63 | 59 | COPY renv /project/renv |
64 | 60 |
|
65 | 61 | # 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)' |
67 | 63 |
|
68 | 64 | # Copy Python requirements file if exists (cached separately) |
69 | 65 | 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}" |
72 | 68 |
|
73 | 69 | # Copy the rest of the project |
74 | 70 | COPY . /project |
|
0 commit comments