Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
189 lines (164 loc) · 5.62 KB
/
Copy pathDockerfile
File metadata and controls
189 lines (164 loc) · 5.62 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
ARG R_VERSION=latest
FROM rocker/rstudio:${R_VERSION}
LABEL "source"="https://github.com/carpentries/workbench-docker/Dockerfile"
LABEL "maintainer.name"="Robert Davey"
LABEL "maintainer.email"="robertdavey@carpentries.org"
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
WORKDIR /home/rstudio
# copy over all scripts
COPY .Renviron /home/rstudio/.Renviron
RUN <<RENVR
chown -R rstudio:rstudio /home/rstudio/.Renviron
RENVR
COPY .env /home/rstudio/.env
RUN <<DOTENV
chmod +rx /home/rstudio/.env
chown rstudio:rstudio /home/rstudio/.env
DOTENV
COPY local_entrypoint.sh .
RUN <<LENTRY
chmod +x local_entrypoint.sh
chown rstudio:rstudio local_entrypoint.sh
LENTRY
COPY start.sh .
RUN <<START
chmod +x start.sh
chown rstudio:rstudio start.sh
START
COPY scripts/* /home/rstudio/.workbench/
RUN <<INITENV
chmod +x /home/rstudio/.workbench/*
chown -R rstudio:rstudio /home/rstudio/.workbench
source /home/rstudio/.workbench/init_env.sh
INITENV
# update and install base build tools
RUN <<BUILDDEPS
apt-get update
apt-get install -y git autoconf build-essential software-properties-common
BUILDDEPS
RUN <<APTSRC
(type -p wget >/dev/null || (apt install wget -y))
mkdir -p -m 755 /etc/apt/keyrings
out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg
cat $out | tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null
chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg
mkdir -p -m 755 /etc/apt/sources.list.d
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null
apt update
APTSRC
# Install system dependencies
RUN <<APTGET
apt-get install -y \
jq \
zlib1g-dev \
libcurl4-openssl-dev \
libfontconfig-dev \
libfreetype-dev \
libfribidi-dev \
libharfbuzz-dev \
libicu-dev \
libgit2-dev \
libjpeg-turbo8-dev \
libpng-dev \
libuv1-dev \
libxml2-dev \
libxslt1-dev \
libssl-dev \
libtiff-dev \
libx11-dev \
libgdal-dev \
libcairo2-dev \
libglpk-dev \
libmagick++-dev \
libnode-dev \
libudunits2-dev \
gdal-bin \
xdg-utils \
pngquant \
pandoc \
curl \
ssh \
nano \
gh \
cmake \
rsync \
wget \
bzip2 \
ca-certificates
apt-get clean all
apt-get purge
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
APTGET
RUN <<AWSCLI
arch=$(arch)
curl "https://awscli.amazonaws.com/awscli-exe-linux-${arch}.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
rm -rf awscliv2.zip ./aws
aws --version
AWSCLI
ENV CONDA_DIR=/opt/conda
ENV PATH=${CONDA_DIR}/bin:${PATH}
ENV MINIFORGE_VERSION="${MINIFORGE_VERSION:-26.9.4-1}"
ENV MINIFORGE_NAME="${MINIFORGE_NAME:-Miniforge3}"
# taken from the conda-forge miniforge installation instructions
RUN <<CONDA
wget --no-hsts --quiet https://github.com/conda-forge/miniforge/releases/download/${MINIFORGE_VERSION}/${MINIFORGE_NAME}-${MINIFORGE_VERSION}-Linux-$(uname -m).sh -O /tmp/miniforge.sh && \
/bin/bash /tmp/miniforge.sh -b -p ${CONDA_DIR} && \
rm /tmp/miniforge.sh && \
conda clean --tarballs --index-cache --packages --yes && \
find ${CONDA_DIR} -follow -type f -name '*.a' -delete && \
find ${CONDA_DIR} -follow -type f -name '*.pyc' -delete && \
conda clean --force-pkgs-dirs --all --yes && \
echo ". ${CONDA_DIR}/etc/profile.d/conda.sh && conda activate base" >> /etc/skel/.bashrc && \
echo ". ${CONDA_DIR}/etc/profile.d/conda.sh && conda activate base" >> ~/.bashrc
CONDA
ENV QUARTO_VERSION="${QUARTO_VERSION:-1.11.9}"
# install quarto
# e.g. https://github.com/quarto-dev/quarto-cli/releases/download/v1.11.9/quarto-1.11.9-linux-amd64.deb
RUN <<QUARTO
arch=$(dpkg --print-architecture)
wget --no-hsts --quiet https://github.com/quarto-dev/quarto-cli/releases/download/v${QUARTO_VERSION}/quarto-${QUARTO_VERSION}-linux-${arch}.deb -O /tmp/quarto.deb && \
sudo dpkg -i /tmp/quarto.deb && \
rm /tmp/quarto.deb
QUARTO
RUN echo "rstudio ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers
# setup base renv for lessons that want to use it
RUN --mount=type=secret,id=github_token <<BASE
if grep -qE '^\s*GITHUB_PAT\s*=' /home/rstudio/.Renviron 2>/dev/null; then
echo "GITHUB_PAT already defined in .Renviron, skipping CI secret"
else
export GITHUB_PAT=$(cat /run/secrets/github_token)
fi
R -e 'install.packages(c("renv", "remotes", "httpuv", "httr", "cffr", "gh", "yaml", "quarto"), repos = c(CRAN = "https://cloud.r-project.org"))'
BASE
# enable build args
ARG SANDPAPER_REF
ARG VARNISH_REF
ARG PEGBOARD_REF
ARG NO_LATEST
# Convert ARG to ENV so they persist inside the container
ENV SANDPAPER_REF=${SANDPAPER_REF}
ENV VARNISH_REF=${VARNISH_REF}
ENV PEGBOARD_REF=${PEGBOARD_REF}
ENV NO_LATEST=${NO_LATEST}
# install dependencies and workbench packages
RUN --mount=type=secret,id=github_token <<DEPS
if grep -qE '^\s*GITHUB_PAT\s*=' /home/rstudio/.Renviron 2>/dev/null; then
echo "GITHUB_PAT already defined in .Renviron, skipping CI secret"
else
export GITHUB_PAT=$(cat /run/secrets/github_token)
fi
Rscript /home/rstudio/.workbench/deps.R
DEPS
RUN --mount=type=secret,id=github_token <<WBDEPS
if grep -qE '^\s*GITHUB_PAT\s*=' /home/rstudio/.Renviron 2>/dev/null; then
echo "GITHUB_PAT already defined in .Renviron, skipping CI secret"
else
export GITHUB_PAT=$(cat /run/secrets/github_token)
fi
Rscript /home/rstudio/.workbench/wb_deps.R
WBDEPS
# clean up
RUN rm -rf /tmp/downloaded_packages