Skip to content

Commit afa47dd

Browse files
committed
Updated docker config files from
https://github.com/taniwallach/ww_docker_config_sets/tree/master/WW-2.14-ubuntu_16.04 which overcome several issues: * docker-compose.yml: MariaDB on Dockers CE for Windows cannot function with bind mounted /var/lib/mysql at least with the default settings. Using a named volume for the persistent storage instead. * Dockerfile: Hardwired the PG branch (@mgage) and merge ENV lines (@nmoller), and additional reorganization * docker-entrypoint.sh: Create modelCourse directory and automatically run OPL-update on initial container startup, misc additional start-up time actions (@taniwallach) * Add some additional files to .dockerignore * PG_VERSION as a file, to match what the Dockerfile uses, so that the symbolic link cannot cause trouble/confusion in Docker installs.
1 parent cb8b87d commit afa47dd

5 files changed

+86
-43
lines changed

.dockerignore

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
Dockerfile
22
logs/*
33
tmp/*
4+
htdocs/tmp/*
5+
htdocs/DATA/library*.json
6+
htdocs/DATA/tagging-taxonomy.json
7+
htdocs/DATA/textbooks-tree.json
48
.git
59
.data
610
.idea

Dockerfile

+48-41
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
11
FROM ubuntu:16.04
22

3-
ENV WEBWORK_URL /webwork2
4-
ENV WEBWORK_ROOT_URL http://localhost
5-
ENV WEBWORK_DB_HOST db
6-
ENV WEBWORK_DB_PORT 3306
7-
ENV WEBWORK_DB_NAME webwork
8-
ENV WEBWORK_DB_DSN DBI:mysql:${WEBWORK_DB_NAME}:${WEBWORK_DB_HOST}:${WEBWORK_DB_PORT}
9-
ENV WEBWORK_DB_USER webworkWrite
10-
ENV WEBWORK_DB_PASSWORD passwordRW
11-
ENV WEBWORK_SMTP_SERVER localhost
12-
ENV WEBWORK_SMTP_SENDER [email protected]
13-
ENV WEBWORK_TIMEZONE America/New_York
14-
ENV APACHE_RUN_USER www-data
15-
ENV APACHE_RUN_GROUP www-data
16-
# temporary state file location. This might be changed to /run in Wheezy+1
17-
ENV APACHE_PID_FILE /var/run/apache2/apache2.pid
18-
ENV APACHE_RUN_DIR /var/run/apache2
19-
ENV APACHE_LOCK_DIR /var/lock/apache2
20-
# Only /var/log/apache2 is handled by /etc/logrotate.d/apache2.
21-
ENV APACHE_LOG_DIR /var/log/apache2
22-
ENV APP_ROOT /opt/webwork
23-
ENV WEBWORK_ROOT $APP_ROOT/webwork2
24-
ENV PG_ROOT $APP_ROOT/pg
25-
ENV DEV 0
26-
3+
ENV PG_BRANCH=rel-PG-2.14 \
4+
WEBWORK_URL=/webwork2 \
5+
WEBWORK_ROOT_URL=http://localhost \
6+
WEBWORK_DB_HOST=db \
7+
WEBWORK_DB_PORT=3306 \
8+
WEBWORK_DB_NAME=webwork \
9+
WEBWORK_DB_USER=webworkWrite \
10+
WEBWORK_DB_PASSWORD=passwordRW \
11+
WEBWORK_SMTP_SERVER=localhost \
12+
13+
WEBWORK_TIMEZONE=America/New_York \
14+
APACHE_RUN_USER=www-data \
15+
APACHE_RUN_GROUP=www-data \
16+
# temporary state file location. This might be changed to /run in Wheezy+1 \
17+
APACHE_PID_FILE=/var/run/apache2/apache2.pid \
18+
APACHE_RUN_DIR=/var/run/apache2 \
19+
APACHE_LOCK_DIR=/var/lock/apache2 \
20+
# Only /var/log/apache2 is handled by /etc/logrotate.d/apache2.
21+
APACHE_LOG_DIR=/var/log/apache2 \
22+
APP_ROOT=/opt/webwork \
23+
DEV=0
24+
25+
ENV WEBWORK_DB_DSN=DBI:mysql:${WEBWORK_DB_NAME}:${WEBWORK_DB_HOST}:${WEBWORK_DB_PORT} \
26+
WEBWORK_ROOT=$APP_ROOT/webwork2 \
27+
PG_ROOT=$APP_ROOT/pg \
28+
PATH=$PATH:$APP_ROOT/webwork2/bin
2729

2830
RUN apt-get update \
2931
&& apt-get install -y --no-install-recommends --no-install-suggests \
@@ -78,35 +80,40 @@ RUN apt-get update \
7880

7981
RUN mkdir -p $APP_ROOT/courses $APP_ROOT/libraries $APP_ROOT/webwork2
8082

81-
COPY VERSION /tmp
82-
83-
RUN WEBWORK_VERSION=`cat /tmp/VERSION|sed -n 's/.*\(develop\)'\'';/\1/p' && cat /tmp/VERSION|sed -n 's/.*\([0-9]\.[0-9]*\)'\'';/PG\-\1/p'` \
84-
&& curl -fSL https://github.com/openwebwork/pg/archive/${WEBWORK_VERSION}.tar.gz -o /tmp/${WEBWORK_VERSION}.tar.gz \
85-
&& tar xzf /tmp/${WEBWORK_VERSION}.tar.gz \
86-
&& mv pg-${WEBWORK_VERSION} $APP_ROOT/pg \
87-
&& rm /tmp/${WEBWORK_VERSION}.tar.gz \
83+
# Block to include webwork2 in the container, when needed, instead of getting it from a bind mount.
84+
# Uncomment when needed, and set the correct branch name on the following line.
85+
#ENV WEBWORK_BRANCH=rel-ww2.14 # need a valid branch name from https://github.com/openwebwork/webwork2
86+
#RUN curl -fSL https://github.com/openwebwork/webwork2/archive/${WEBWORK_BRANCH}.tar.gz -o /tmp/${WEBWORK_BRANCH}.tar.gz \
87+
# && cd /tmp \
88+
# && tar xzf /tmp/${WEBWORK_BRANCH}.tar.gz \
89+
# && mv webwork2-${WEBWORK_BRANCH} $APP_ROOT/webwork2 \
90+
# && rm -rf /tmp/${WEBWORK_BRANCH}.tar.gz /tmp/webwork2-${WEBWORK_BRANCH}
91+
92+
RUN curl -fSL https://github.com/openwebwork/pg/archive/${PG_BRANCH}.tar.gz -o /tmp/${PG_BRANCH}.tar.gz \
93+
&& tar xzf /tmp/${PG_BRANCH}.tar.gz \
94+
&& mv pg-${PG_BRANCH} $APP_ROOT/pg \
95+
&& rm /tmp/${PG_BRANCH}.tar.gz \
8896
&& curl -fSL https://github.com/openwebwork/webwork-open-problem-library/archive/master.tar.gz -o /tmp/opl.tar.gz \
8997
&& tar xzf /tmp/opl.tar.gz \
9098
&& mv webwork-open-problem-library-master $APP_ROOT/libraries/webwork-open-problem-library \
9199
&& rm /tmp/opl.tar.gz \
92100
&& curl -fSL https://github.com/mathjax/MathJax/archive/master.tar.gz -o /tmp/mathjax.tar.gz \
93101
&& tar xzf /tmp/mathjax.tar.gz \
94102
&& mv MathJax-master $APP_ROOT/MathJax \
95-
&& rm /tmp/mathjax.tar.gz \
96-
&& rm /tmp/VERSION
97-
#curl -fSL https://github.com/openwebwork/webwork2/archive/WeBWorK-${WEBWORK_VERSION}.tar.gz -o /tmp/WeBWorK-${WEBWORK_VERSION}.tar.gz \
98-
#&& tar xzf /tmp/WeBWorK-${WEBWORK_VERSION}.tar.gz \
99-
#&& mv webwork2-WeBWorK-${WEBWORK_VERSION} $APP_ROOT/webwork2 \
100-
#&& rm /tmp/WeBWorK-${WEBWORK_VERSION}.tar.gz \
103+
&& rm /tmp/mathjax.tar.gz
104+
101105

102106
RUN echo "PATH=$PATH:$APP_ROOT/webwork2/bin" >> /root/.bashrc
103107

104108
COPY . $APP_ROOT/webwork2
105109

106-
RUN cd $APP_ROOT/webwork2/courses.dist \
107-
&& cp *.lst $APP_ROOT/courses/ \
108-
&& cp -R modelCourse $APP_ROOT/courses/ \
109-
&& cd $APP_ROOT/pg/lib/chromatic \
110+
# Move these lines into docker-entrypoint.sh so the bind mount of courses
111+
# will be available
112+
#RUN cd $APP_ROOT/webwork2/courses.dist \
113+
# && cp *.lst $APP_ROOT/courses/ \
114+
# && cp -R modelCourse $APP_ROOT/courses/
115+
116+
RUN cd $APP_ROOT/pg/lib/chromatic \
110117
&& gcc color.c -o color
111118

112119
# setup apache

PG_VERSION

-1
This file was deleted.

PG_VERSION

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
$PG_VERSION ='PG-2.14';
2+
$PG_COPYRIGHT_YEARS = '1996-2018';
3+
4+
1;

docker-compose.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ services:
33
db:
44
image: mariadb:10.1
55
volumes:
6-
- "./.data/db:/var/lib/mysql"
6+
- mysql:/var/lib/mysql
77
restart: always
88
environment:
99
MYSQL_ROOT_PASSWORD: randomepassword
@@ -31,3 +31,5 @@ services:
3131
image: ubcctlt/rserve
3232
ports:
3333
- "6311:6311"
34+
volumes:
35+
mysql:

docker-entrypoint.sh

+27
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,29 @@ if [ "$1" = 'apache2' ]; then
3737
chown www-data:root -R $APP_ROOT/courses
3838
echo "Admin course is created."
3939
fi
40+
# modelCourses link if not existing
41+
if [ ! -d "$APP_ROOT/courses/modelCourse" ]; then
42+
echo "create modelCourse subdirectory"
43+
rm -rf $APP_ROOT/courses/modelCourse
44+
cd $APP_ROOT/webwork2/courses.dist
45+
cp -R modelCourse $APP_ROOT/courses/
46+
fi
47+
# defaultClasslist.lst and adminClasslist.lst files if not existing
48+
if [ ! -f "$APP_ROOT/courses/defaultClasslist.lst" ]; then
49+
echo "defaultClasslist.lst is being created"
50+
cd $APP_ROOT/webwork2/courses.dist
51+
cp *.lst $APP_ROOT/courses/
52+
fi
53+
if [ ! -f "$APP_ROOT/courses/adminClasslist.lst" ]; then
54+
echo "adminClasslist.lst is being created"
55+
cd $APP_ROOT/webwork2/courses.dist
56+
cp *.lst $APP_ROOT/courses/
57+
fi
58+
# run OPL-update if necessary
59+
if [ ! -f "$APP_ROOT/webwork2/htdocs/DATA/tagging-taxonomy.json" ]; then
60+
cd $APP_ROOT/webwork2/bin
61+
./OPL-update
62+
fi
4063
# generate apache2 reload config if needed
4164
if [ $DEV -eq 1 ]; then
4265
echo "PerlModule Apache2::Reload" > /etc/apache2/conf-enabled/apache2-reload.conf
@@ -45,6 +68,10 @@ if [ "$1" = 'apache2' ]; then
4568
else
4669
rm -f /etc/apache2/conf-enabled/apache2-reload.conf
4770
fi
71+
# Fix possible permission issues
72+
cd $APP_ROOT/webwork2
73+
chown -R www-data logs tmp DATA htdocs/tmp ../courses
74+
chmod -R u+w logs tmp DATA htdocs/tmp ../courses
4875
fi
4976

5077
exec "$@"

0 commit comments

Comments
 (0)