-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
93 lines (76 loc) · 2.99 KB
/
Dockerfile
File metadata and controls
93 lines (76 loc) · 2.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
FROM ubuntu:24.04
# Non-interactive and locale
ENV DEBIAN_FRONTEND=noninteractive
# System dependencies (R 4.4+ from CRAN, wget, etc.)
RUN apt-get update && \
apt-get install -y --no-install-recommends \
wget \
ca-certificates \
gnupg \
software-properties-common \
dirmngr \
locales \
git && \
locale-gen en_GB.UTF-8 && \
rm -rf /var/lib/apt/lists/*
# System libraries needed for ragg and other graphics packages
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
libwebpmux3 \
libwebp-dev \
libpng-dev \
libjpeg-dev \
libtiff5-dev \
libfreetype6-dev \
pkg-config \
&& rm -rf /var/lib/apt/lists/*
ENV LANG=en_GB.UTF-8
ENV LC_ALL=en_GB.UTF-8
# Add CRAN repo for R >= 4.4 on Ubuntu 24.04 (noble)
RUN wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | \
gpg --dearmor -o /usr/share/keyrings/r-project.gpg && \
echo "deb [signed-by=/usr/share/keyrings/r-project.gpg] https://cloud.r-project.org/bin/linux/ubuntu noble-cran40/" \
> /etc/apt/sources.list.d/r-project.list && \
apt-get update && \
apt-get install -y --no-install-recommends \
r-base \
r-base-dev && \
rm -rf /var/lib/apt/lists/*
# Install Quarto CLI
RUN wget -qO /tmp/quarto.deb https://quarto.org/download/latest/quarto-linux-amd64.deb && \
apt-get update && \
apt-get install -y /tmp/quarto.deb && \
rm /tmp/quarto.deb && \
rm -rf /var/lib/apt/lists/*
# Install Miniconda
ENV CONDA_DIR=/opt/conda
RUN wget -qO /tmp/miniconda.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && \
bash /tmp/miniconda.sh -b -p "$CONDA_DIR" && \
rm /tmp/miniconda.sh
ENV PATH="$CONDA_DIR/bin:${PATH}"
# Configure conda for non-interactive use and faster solving
RUN conda config --system --set always_yes yes && \
conda config --system --set changeps1 no
# Accept Anaconda ToS for required channels in non-interactive builds
RUN conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/main && \
conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/r
# Copy project
WORKDIR /workspace
COPY . /workspace
# Remove .Renviron if it was copied (to avoid hardcoded host paths)
RUN rm -f /workspace/.Renviron
# Create the conda environment
RUN conda env create -f environment.yaml
# Make the environment active by default
ENV CONDA_DEFAULT_ENV=stars-testing-intro
ENV PATH="/opt/conda/envs/stars-testing-intro/bin:${PATH}"
RUN echo "conda activate stars-testing-intro" >> /root/.bashrc
# R: set renv path and restore packages
ENV RENV_PATHS_LIBRARY=/workspace/renv/library
# Install renv and restore R packages
RUN Rscript -e "install.packages('renv', repos = 'https://cloud.r-project.org')" && \
Rscript -e "renv::restore()"
# Set conda environment as default for reticulate
ENV RETICULATE_PYTHON=/opt/conda/envs/stars-testing-intro/bin/python
# Default command
CMD ["/bin/bash"]