|
1 | | -# 1. Use R 4.5.1 (Matches Rocker's Ubuntu 24.04 based image) |
| 1 | +# 1. Use R 4.5.1 |
2 | 2 | FROM rocker/r-ver:4.5.1 |
3 | 3 |
|
4 | 4 | # 2. Install system dependencies |
5 | | -# Added libharfbuzz-dev, libfribidi-dev, and libfreetype6-dev for 'ragg' |
6 | 5 | RUN apt-get update && apt-get install -y --no-install-recommends \ |
7 | | - libxml2-dev \ |
8 | | - libssl-dev \ |
9 | | - libcurl4-openssl-dev \ |
10 | | - libpng-dev \ |
11 | | - libjpeg-dev \ |
12 | | - libtiff-dev \ |
13 | | - libfreetype6-dev \ |
14 | | - libharfbuzz-dev \ |
15 | | - libfribidi-dev \ |
16 | | - libicu-dev \ |
17 | | - libglpk-dev \ |
18 | | - zlib1g-dev \ |
19 | | - gfortran \ |
20 | | - pandoc \ |
21 | | - pkg-config \ |
| 6 | + libxml2-dev libssl-dev libcurl4-openssl-dev libpng-dev \ |
| 7 | + libjpeg-dev libtiff-dev libfreetype6-dev libharfbuzz-dev \ |
| 8 | + libfribidi-dev libicu-dev libglpk-dev zlib1g-dev \ |
| 9 | + gfortran pandoc pkg-config \ |
22 | 10 | && rm -rf /var/lib/apt/lists/* |
23 | 11 |
|
24 | | -# 3. Setup Environment for Speed and Persistence |
| 12 | +# 3. Setup Environment |
| 13 | +ENV R_LIBS_USER=/opt/renv/library |
25 | 14 | ENV RENV_PATHS_LIBRARY=/opt/renv/library |
26 | | -# Using the 'noble' (Ubuntu 24.04) binary repo for speed |
27 | | -ENV RENV_CONFIG_REPOS_OVERRIDE="https://packagemanager.posit.co/cran/__linux__/noble/latest" |
28 | | -ENV RENV_DOWNLOAD_METHOD="libcurl" |
29 | | - |
| 15 | +ENV R_PROFILE_USER=/dev/null |
30 | 16 | WORKDIR /project |
31 | 17 |
|
32 | | -# 4. Setup and Restore |
33 | | -# Copy only the lockfile first to maximize Docker layer caching |
| 18 | +# 4. Restore Packages (Cached Layer) |
34 | 19 | COPY renv.lock .Rprofile ./ |
35 | 20 | COPY renv/activate.R renv/activate.R |
36 | | - |
37 | 21 | RUN mkdir -p /opt/renv/library |
38 | | -RUN R -e "options(Ncpus = parallel::detectCores()); renv::restore(library='/opt/renv/library')" |
| 22 | +RUN R -e "renv::restore(library='/opt/renv/library')" |
39 | 23 |
|
40 | | -# 5. Copy Application Files |
41 | | -COPY *.Rmd ./ |
42 | | -COPY _site.ym[l] ./ |
| 24 | +# 5. Copy ALL Application Files |
| 25 | +# This brings in 3PodR.R, chapters/, R/, and everything else |
| 26 | +COPY . . |
43 | 27 |
|
44 | | -# 6. Flexible Execution |
45 | | -ENTRYPOINT ["sh", "-c", "R -e \"rmarkdown::render_site(config_file = '$1')\"", "--"] |
| 28 | +# 6. Execution Logic |
| 29 | +# We use a symlink so that whatever config file you pass at runtime |
| 30 | +# becomes the "configuration.yml" your R code expects. |
| 31 | +ENTRYPOINT ["sh", "-c", "ln -sf /project/$1 /project/configuration.yml && R --vanilla -e 'bookdown::render_book(\"index.Rmd\")'", "--"] |
46 | 32 |
|
47 | | -# Default argument |
48 | | -CMD ["_site.yml"] |
| 33 | +CMD ["configuration.yml"] |
0 commit comments