1-
21# Optional things to change/configure below:
32#
43# 1. Which branch of webwork2/ and pg/ to install.
3029# Make sure to use a valid setting.
3130# "/usr/bin/timedatectl list-timezones" on Ubuntu will find valid values
3231# ADD_APT_PACKAGES="package1 package2 package3"
33- # will have these additional Ubuntu packages installed at startup.
34- #
35- # ==================================================================
32+ # will have these additional Ubuntu packages installed at startup.
3633
34+ # ==================================================================
3735# Phase 1 - download some Git repos for later use:
3836# as suggested by Nelson Moller in https://gist.github.com/nmoller/81bd8e149e6aa2a7cf051e0bf248b2e2
3937
@@ -48,63 +46,60 @@ ARG PG_BRANCH
4846WORKDIR /opt/base
4947
5048RUN echo Cloning branch $WEBWORK2_BRANCH from $WEBWORK2_GIT_URL \
51- && echo git clone --single-branch --branch ${WEBWORK2_BRANCH} --depth 1 $WEBWORK2_GIT_URL \
52- && git clone --single-branch --branch ${WEBWORK2_BRANCH} --depth 1 $WEBWORK2_GIT_URL \
53- && rm -rf webwork2/.git webwork2/{*ignore,Dockerfile,docker-compose.yml,docker-config}
49+ && echo git clone --single-branch --branch ${WEBWORK2_BRANCH} --depth 1 $WEBWORK2_GIT_URL \
50+ && git clone --single-branch --branch ${WEBWORK2_BRANCH} --depth 1 $WEBWORK2_GIT_URL \
51+ && rm -rf webwork2/.git webwork2/{*ignore,Dockerfile,docker-compose.yml,docker-config}
5452
5553RUN echo Cloning branch $PG_BRANCH branch from $PG_GIT_URL \
56- && echo git clone --single-branch --branch ${PG_BRANCH} --depth 1 $PG_GIT_URL \
57- && git clone --single-branch --branch ${PG_BRANCH} --depth 1 $PG_GIT_URL \
58- && rm -rf pg/.git
54+ && echo git clone --single-branch --branch ${PG_BRANCH} --depth 1 $PG_GIT_URL \
55+ && git clone --single-branch --branch ${PG_BRANCH} --depth 1 $PG_GIT_URL \
56+ && rm -rf pg/.git
5957
6058# Optional - include OPL (also need to uncomment further below when an included OPL is desired):
61- # RUN git clone --single-branch --branch master --depth 1 https://github.com/openwebwork/webwork-open-problem-library.git \
59+ # RUN git clone --single-branch --branch main --depth 1 https://github.com/openwebwork/webwork-open-problem-library.git \
6260# && rm -rf webwork-open-problem-library/.git
6361
6462# ==================================================================
65-
6663# Phase 2 - set ENV variables
6764
6865# we need to change FROM before setting the ENV variables
6966
7067FROM ubuntu:20.04
7168
7269ENV WEBWORK_URL=/webwork2 \
73- WEBWORK_ROOT_URL=http://localhost \
74- WEBWORK_SMTP_SERVER=localhost \
75- WEBWORK_SMTP_SENDER=webwork@example.com \
76- WEBWORK_TIMEZONE=America/New_York \
77- APACHE_RUN_USER=www-data \
78- APACHE_RUN_GROUP=www-data \
79- # temporary state file location. This might be changed to /run in Wheezy+1 \
80- APACHE_PID_FILE=/var/run/apache2/apache2.pid \
81- APACHE_RUN_DIR=/var/run/apache2 \
82- APACHE_LOCK_DIR=/var/lock/apache2 \
83- # Only /var/log/apache2 is handled by /etc/logrotate.d/apache2.
84- APACHE_LOG_DIR=/var/log/apache2 \
85- APP_ROOT=/opt/webwork \
86- DEBIAN_FRONTEND=noninteractive \
87- DEBCONF_NONINTERACTIVE_SEEN=true \
88- DEV=0
70+ WEBWORK_ROOT_URL=http://localhost \
71+ WEBWORK_SMTP_SERVER=localhost \
72+ WEBWORK_SMTP_SENDER=webwork@example.com \
73+ WEBWORK_TIMEZONE=America/New_York \
74+ APACHE_RUN_USER=www-data \
75+ APACHE_RUN_GROUP=www-data \
76+ # temporary state file location. This might be changed to /run in Wheezy+1 \
77+ APACHE_PID_FILE=/var/run/apache2/apache2.pid \
78+ APACHE_RUN_DIR=/var/run/apache2 \
79+ APACHE_LOCK_DIR=/var/lock/apache2 \
80+ # Only /var/log/apache2 is handled by /etc/logrotate.d/apache2.
81+ APACHE_LOG_DIR=/var/log/apache2 \
82+ APP_ROOT=/opt/webwork \
83+ DEBIAN_FRONTEND=noninteractive \
84+ DEBCONF_NONINTERACTIVE_SEEN=true \
85+ DEV=0
86+
87+ ARG ADDITIONAL_BASE_IMAGE_PACKAGES
8988
9089# Environment variables which depend on a prior environment variable must be set
9190# in an ENV call after the dependencies were defined.
9291ENV WEBWORK_ROOT=$APP_ROOT/webwork2 \
93- PG_ROOT=$APP_ROOT/pg \
94- PATH=$PATH:$APP_ROOT/webwork2/bin
92+ PG_ROOT=$APP_ROOT/pg \
93+ PATH=$PATH:$APP_ROOT/webwork2/bin
9594
9695# ==================================================================
97-
9896# Phase 3 - Ubuntu 20.04 base image + required packages
9997
100- # Packages changes/added for ubuntu 20.04:
101- # libcgi-pm-perl (for CGI::Cookie), libdbd-mariadb-perl
102-
10398# Do NOT include "apt-get -y upgrade"
10499# see: https://docs.docker.com/develop/develop-images/dockerfile_best-practices/
105100
106101RUN apt-get update \
107- && apt-get install -y --no-install-recommends --no-install-suggests \
102+ && apt-get install -y --no-install-recommends --no-install-suggests \
108103 apache2 \
109104 curl \
110105 dvipng \
@@ -181,6 +176,8 @@ RUN apt-get update \
181176 libjson-xs-perl \
182177 libjson-maybexs-perl \
183178 libcpanel-json-xs-perl \
179+ libyaml-libyaml-perl \
180+ libemail-stuffer-perl \
184181 make \
185182 netpbm \
186183 patch \
@@ -208,16 +205,16 @@ RUN apt-get update \
208205 zip \
209206 iputils-ping \
210207 imagemagick \
211- jq \
212- npm \
213- && apt-get clean \
214- && rm -fr /var/lib/apt/lists/* /tmp/*
208+ jq $ADDITIONAL_BASE_IMAGE_PACKAGES \
209+ && curl -fsSL https://deb.nodesource.com/setup_16.x | bash - \
210+ && apt-get install -y --no-install-recommends --no-install-suggests nodejs \
211+ && apt-get clean \
212+ && rm -fr /var/lib/apt/lists/* /tmp/*
215213
216214# Developers may want to add additional packages inside the image
217215# such as: telnet vim mc file
218216
219217# ==================================================================
220-
221218# Phase 4 - Install webwork2 and pg which were downloaded to /opt/base/ in phase 1
222219# Option: Install the OPL in the image also (about 850 MB)
223220
@@ -242,33 +239,33 @@ COPY --from=base /opt/base/pg $APP_ROOT/pg
242239# 6. Install third party javascript files.
243240
244241RUN echo "PATH=$PATH:$APP_ROOT/webwork2/bin" >> /root/.bashrc \
245- && cd $APP_ROOT/pg/lib/chromatic && gcc color.c -o color \
246- && cd $APP_ROOT/webwork2/ \
247- && chown www-data DATA ../courses htdocs/applets logs tmp $APP_ROOT/pg/lib/chromatic \
248- && chmod -R u+w DATA ../courses htdocs/applets logs tmp $APP_ROOT/pg/lib/chromatic \
249- && echo "en_US ISO-8859-1\n en_US.UTF-8 UTF-8" > /etc/locale.gen \
250- && /usr/sbin/locale-gen \
251- && echo "locales locales/default_environment_locale select en_US.UTF-8\n debconf debconf/frontend select Noninteractive" > /tmp/preseed.txt \
252- && debconf-set-selections /tmp/preseed.txt \
253- && rm /etc/localtime /etc/timezone && echo "Etc/UTC" > /etc/timezone \
254- && dpkg-reconfigure -f noninteractive tzdata \
255- && cd $WEBWORK_ROOT/htdocs \
256- && npm install
242+ && cd $APP_ROOT/pg/lib/chromatic && gcc color.c -o color \
243+ && cd $APP_ROOT/webwork2/ \
244+ && chown www-data DATA ../courses logs tmp $APP_ROOT/pg/lib/chromatic \
245+ && chmod -R u+w DATA ../courses logs tmp $APP_ROOT/pg/lib/chromatic \
246+ && echo "en_US ISO-8859-1\n en_US.UTF-8 UTF-8" > /etc/locale.gen \
247+ && /usr/sbin/locale-gen \
248+ && echo "locales locales/default_environment_locale select en_US.UTF-8\n debconf debconf/frontend select Noninteractive" > /tmp/preseed.txt \
249+ && debconf-set-selections /tmp/preseed.txt \
250+ && rm /etc/localtime /etc/timezone && echo "Etc/UTC" > /etc/timezone \
251+ && dpkg-reconfigure -f noninteractive tzdata \
252+ && cd $WEBWORK_ROOT/htdocs \
253+ && npm install \
254+ && cd $PG_ROOT/htdocs \
255+ && npm install
257256
258257# These lines were moved into docker-entrypoint.sh so the bind mount of courses will be available
259258# RUN cd $APP_ROOT/webwork2/courses.dist \
260259# && cp *.lst $APP_ROOT/courses/ \
261260# && cp -R modelCourse $APP_ROOT/courses/
262261
263262# ==================================================================
264-
265263# Phase 6 - install additional Perl modules from CPAN (not packaged for Ubuntu or outdated in Ubuntu)
266264
267265RUN cpanm install Statistics::R::IO \
268- && rm -fr ./cpanm /root/.cpanm /tmp/*
266+ && rm -fr ./cpanm /root/.cpanm /tmp/*
269267
270268# ==================================================================
271-
272269# Phase 7 - setup apache
273270
274271# Note we always create the /etc/ssl/local directory in case it will be needed, as
@@ -284,19 +281,18 @@ COPY docker-config/imagemagick-allow-pdf-read.patch /tmp
284281# However SSL will only be enabled at container startup via docker-entrypoint.sh.
285282
286283RUN cd $APP_ROOT/webwork2/conf \
287- && cp webwork.apache2.4-config.dist webwork.apache2.4-config \
288- && cp $APP_ROOT/webwork2/conf/webwork.apache2.4-config /etc/apache2/conf-enabled/webwork.conf \
289- && a2dismod mpm_event \
290- && a2enmod mpm_prefork \
291- && sed -i -e 's/Timeout 300/Timeout 1200/' /etc/apache2/apache2.conf \
292- && sed -i -e 's/MaxRequestWorkers 150/MaxRequestWorkers 20/' \
293- -e 's/MaxConnectionsPerChild 0/MaxConnectionsPerChild 100/' \
294- /etc/apache2/mods-available/mpm_prefork.conf \
295- && cp $APP_ROOT/webwork2/htdocs/favicon.ico /var/www/html \
296- && mkdir -p $APACHE_RUN_DIR $APACHE_LOCK_DIR $APACHE_LOG_DIR \
297- && mkdir /etc/ssl/local \
298- && a2enmod rewrite \
299- && sed -i -e 's/^<Perl>$/\
284+ && cp webwork.apache2.4-config.dist webwork.apache2.4-config \
285+ && cp $APP_ROOT/webwork2/conf/webwork.apache2.4-config /etc/apache2/conf-enabled/webwork.conf \
286+ && a2dismod mpm_event \
287+ && a2enmod mpm_prefork rewrite \
288+ && sed -i -e 's/Timeout 300/Timeout 1200/' /etc/apache2/apache2.conf \
289+ && sed -i -e 's/MaxRequestWorkers 150/MaxRequestWorkers 20/' \
290+ -e 's/MaxConnectionsPerChild 0/MaxConnectionsPerChild 100/' \
291+ /etc/apache2/mods-available/mpm_prefork.conf \
292+ && cp $APP_ROOT/webwork2/htdocs/favicon.ico /var/www/html \
293+ && mkdir -p $APACHE_RUN_DIR $APACHE_LOCK_DIR $APACHE_LOG_DIR \
294+ && mkdir /etc/ssl/local \
295+ && sed -i -e 's/^<Perl>$/\
300296 PerlPassEnv WEBWORK_URL\n \
301297 PerlPassEnv WEBWORK_ROOT_URL\n \
302298 PerlPassEnv WEBWORK_DB_DRIVER\n \
@@ -324,7 +320,6 @@ WORKDIR $APP_ROOT
324320# EXPOSE 443
325321
326322# ==================================================================
327-
328323# Phase 8 - prepare docker-entrypoint.sh
329324# Done near the end, so that an update to docker-entrypoint.sh can be
330325# done without rebuilding the earlier layers of the Docker image.
@@ -334,14 +329,13 @@ COPY docker-config/docker-entrypoint.sh /usr/local/bin/
334329ENTRYPOINT ["docker-entrypoint.sh" ]
335330
336331# ==================================================================
337-
338332# Add enviroment variables to control some things during container startup
339333
340334ENV SSL=0 \
341- PAPERSIZE=letter \
342- SYSTEM_TIMEZONE=UTC \
343- ADD_LOCALES=0 \
344- ADD_APT_PACKAGES=0
335+ PAPERSIZE=letter \
336+ SYSTEM_TIMEZONE=UTC \
337+ ADD_LOCALES=0 \
338+ ADD_APT_PACKAGES=0
345339
346340# ================================================
347341
0 commit comments