-
-
Notifications
You must be signed in to change notification settings - Fork 165
/
Dockerfile
260 lines (228 loc) · 7.86 KB
/
Dockerfile
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
# ==================================================================
# Phase 1 - Download webwork and pg git repositories.
FROM alpine/git AS base
# Build args specifying the branches for webwork2 and pg used to build the image.
ARG WEBWORK2_GIT_URL
ARG WEBWORK2_BRANCH
ARG PG_GIT_URL
ARG PG_BRANCH
WORKDIR /opt/base
RUN echo Cloning branch $WEBWORK2_BRANCH from $WEBWORK2_GIT_URL \
&& echo git clone --single-branch --branch ${WEBWORK2_BRANCH} --depth 1 $WEBWORK2_GIT_URL \
&& git clone --single-branch --branch ${WEBWORK2_BRANCH} --depth 1 $WEBWORK2_GIT_URL \
&& rm -rf webwork2/.git webwork2/{*ignore,Dockerfile,docker-compose.yml,docker-config}
RUN echo Cloning branch $PG_BRANCH branch from $PG_GIT_URL \
&& echo git clone --single-branch --branch ${PG_BRANCH} --depth 1 $PG_GIT_URL \
&& git clone --single-branch --branch ${PG_BRANCH} --depth 1 $PG_GIT_URL \
&& rm -rf pg/.git
# Optional - include OPL (also need to uncomment further below when an included OPL is desired):
#RUN git clone --single-branch --branch main --depth 1 https://github.com/openwebwork/webwork-open-problem-library.git \
# && rm -rf webwork-open-problem-library/.git
# ==================================================================
# Phase 2 - set ENV variables
# We need to change FROM before setting the ENV variables.
FROM ubuntu:24.04
ENV WEBWORK_URL=/webwork2 \
WEBWORK_ROOT_URL=http://localhost::8080 \
WEBWORK_SMTP_SERVER=localhost \
WEBWORK_SMTP_SENDER=webwork@example.com \
WEBWORK_TIMEZONE=America/New_York \
APP_ROOT=/opt/webwork \
DEBIAN_FRONTEND=noninteractive \
DEBCONF_NONINTERACTIVE_SEEN=true
ARG ADDITIONAL_BASE_IMAGE_PACKAGES
# Environment variables which depend on a prior environment variable must be set
# in an ENV call after the dependencies were defined.
ENV WEBWORK_ROOT=$APP_ROOT/webwork2 \
PG_ROOT=$APP_ROOT/pg \
PATH=$PATH:$APP_ROOT/webwork2/bin
# ==================================================================
# Phase 3 - Install required packages
# Do NOT include "apt-get -y upgrade"
# see: https://docs.docker.com/develop/develop-images/dockerfile_best-practices/
RUN apt-get update \
&& apt-get install -y --no-install-recommends --no-install-suggests \
apt-utils \
ca-certificates \
cpanminus \
culmus \
curl \
debconf-utils \
dvipng \
dvisvgm \
fonts-linuxlibertine \
gcc \
git \
imagemagick \
iputils-ping \
jq \
libarchive-extract-perl \
libarchive-zip-perl \
libarray-utils-perl \
libc6-dev \
libcapture-tiny-perl \
libclass-tiny-antlers-perl \
libclass-tiny-perl \
libcpanel-json-xs-perl \
libcrypt-jwt-perl \
libcryptx-perl \
libdata-dump-perl \
libdata-structure-util-perl \
libdatetime-perl \
libdbd-mysql-perl \
libdevel-checklib-perl \
libemail-address-xs-perl \
libemail-date-format-perl \
libemail-sender-perl \
libemail-stuffer-perl \
libexception-class-perl \
libextutils-config-perl \
libextutils-helpers-perl \
libextutils-installpaths-perl \
libextutils-xsbuilder-perl \
libfile-copy-recursive-perl \
libfile-find-rule-perl-perl \
libfile-sharedir-install-perl \
libfuture-asyncawait-perl \
libgd-barcode-perl \
libgd-perl \
libhtml-scrubber-perl \
libhtml-template-perl \
libhttp-async-perl \
libiterator-perl \
libiterator-util-perl \
libjson-maybexs-perl \
libjson-perl \
libjson-xs-perl \
liblocale-maketext-lexicon-perl \
libmariadb-dev \
libmath-random-secure-perl \
libmime-base32-perl \
libmime-tools-perl \
libminion-backend-sqlite-perl \
libminion-perl \
libmodule-build-perl \
libmodule-pluggable-perl \
libmojolicious-perl \
libmojolicious-plugin-renderfile-perl \
libnet-https-nb-perl \
libnet-ip-perl \
libnet-ldap-perl \
libnet-oauth-perl \
libossp-uuid-perl \
libpadwalker-perl \
libpandoc-wrapper-perl \
libpath-class-perl \
libpath-tiny-perl \
libphp-serialization-perl \
libpod-wsdl-perl \
libsoap-lite-perl \
libsql-abstract-perl \
libstring-shellquote-perl \
libsub-uplevel-perl \
libsvg-perl \
libtemplate-perl \
libtest-deep-perl \
libtest-exception-perl \
libtest-fatal-perl \
libtest-mockobject-perl \
libtest-pod-perl \
libtest-requires-perl \
libtest-warn-perl \
libtest-xml-perl \
libtext-csv-perl \
libthrowable-perl \
libtimedate-perl \
libuniversal-can-perl \
libuniversal-isa-perl \
libuuid-tiny-perl \
libxml-parser-easytree-perl \
libxml-parser-perl \
libxml-semanticdiff-perl \
libxml-simple-perl \
libxml-writer-perl \
libxml-xpath-perl \
libyaml-libyaml-perl \
lmodern \
locales \
make \
mariadb-client \
netpbm \
patch \
pdf2svg \
preview-latex-style \
ssl-cert \
sudo \
texlive \
texlive-lang-arabic \
texlive-lang-other \
texlive-latex-extra \
texlive-plain-generic \
texlive-science \
texlive-xetex \
tzdata \
zip $ADDITIONAL_BASE_IMAGE_PACKAGES \
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
&& apt-get install -y --no-install-recommends --no-install-suggests nodejs \
&& apt-get clean \
&& rm -fr /var/lib/apt/lists/* /tmp/*
# ==================================================================
# Phase 4 - Install additional Perl modules from CPAN that are not packaged for Ubuntu or are outdated in Ubuntu.
RUN cpanm install -n \
Statistics::R::IO \
DBD::MariaDB \
Perl::Tidy@20220613 \
Archive::Zip::SimpleZip \
&& rm -fr ./cpanm /root/.cpanm /tmp/*
# ==================================================================
# Phase 5 - Install webwork2 and pg which were downloaded to /opt/base/ in phase 1
# Option: Install the OPL in the image also (about 850 MB)
RUN mkdir -p $APP_ROOT/courses $APP_ROOT/libraries $APP_ROOT/libraries/webwork-open-problem-library $APP_ROOT/webwork2 /www/www/html
COPY --from=base /opt/base/webwork2 $APP_ROOT/webwork2
COPY --from=base /opt/base/pg $APP_ROOT/pg
# Optional - include OPL (also need to uncomment above to clone from GitHub when needed):
#COPY --from=base /opt/base/webwork-open-problem-library $APP_ROOT/libraries/webwork-open-problem-library
# ==================================================================
# Phase 6 - System configuration
# 1. Setup PATH.
# 2. Create the webwork2 PID directory and the /etc/ssl/local directory in case it is needed.
# 3. Perform initial permissions setup for material INSIDE the image.
# 4. Build standard locales.
# 5. Set the default system timezone to be UTC.
# 6. Install third party javascript files.
# 7. Apply patches
# Patch files that are applied below
COPY docker-config/pgfsys-dvisvmg-bbox-fix.patch /tmp
RUN echo "PATH=$PATH:$APP_ROOT/webwork2/bin" >> /root/.bashrc \
&& mkdir /run/webwork2 /etc/ssl/local \
&& cd $APP_ROOT/webwork2/ \
&& chown www-data DATA ../courses logs tmp /etc/ssl/local /run/webwork2 \
&& chmod -R u+w DATA ../courses logs tmp /run/webwork2 /etc/ssl/local \
&& echo "en_US ISO-8859-1\nen_US.UTF-8 UTF-8" > /etc/locale.gen \
&& /usr/sbin/locale-gen \
&& echo "locales locales/default_environment_locale select en_US.UTF-8\ndebconf debconf/frontend select Noninteractive" > /tmp/preseed.txt \
&& debconf-set-selections /tmp/preseed.txt \
&& rm /etc/localtime /etc/timezone && echo "Etc/UTC" > /etc/timezone \
&& dpkg-reconfigure -f noninteractive tzdata \
&& cd $WEBWORK_ROOT/htdocs \
&& npm install \
&& cd $PG_ROOT/htdocs \
&& npm install \
&& patch -p1 -d / < /tmp/pgfsys-dvisvmg-bbox-fix.patch \
&& rm /tmp/pgfsys-dvisvmg-bbox-fix.patch
# ==================================================================
# Phase 7 - Final setup and prepare docker-entrypoint.sh
# Done near the end, so that an update to docker-entrypoint.sh can be
# done without rebuilding the earlier layers of the Docker image.
EXPOSE 8080
WORKDIR $WEBWORK_ROOT
COPY docker-config/docker-entrypoint.sh /usr/local/bin/
ENTRYPOINT ["docker-entrypoint.sh"]
# Add enviroment variables to control some things during container startup
ENV SSL=0 \
PAPERSIZE=letter \
SYSTEM_TIMEZONE=UTC \
ADD_LOCALES=0 \
ADD_APT_PACKAGES=0
# ================================================
CMD ["sudo", "-E", "-u", "www-data", "hypnotoad", "-f", "bin/webwork2"]