Skip to content

Commit

Permalink
Updated docker config files from
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
taniwallach committed Sep 3, 2018
1 parent cb8b87d commit afa47dd
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 43 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Dockerfile
logs/*
tmp/*
htdocs/tmp/*
htdocs/DATA/library*.json
htdocs/DATA/tagging-taxonomy.json
htdocs/DATA/textbooks-tree.json
.git
.data
.idea
89 changes: 48 additions & 41 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
FROM ubuntu:16.04

ENV WEBWORK_URL /webwork2
ENV WEBWORK_ROOT_URL http://localhost
ENV WEBWORK_DB_HOST db
ENV WEBWORK_DB_PORT 3306
ENV WEBWORK_DB_NAME webwork
ENV WEBWORK_DB_DSN DBI:mysql:${WEBWORK_DB_NAME}:${WEBWORK_DB_HOST}:${WEBWORK_DB_PORT}
ENV WEBWORK_DB_USER webworkWrite
ENV WEBWORK_DB_PASSWORD passwordRW
ENV WEBWORK_SMTP_SERVER localhost
ENV WEBWORK_SMTP_SENDER [email protected]
ENV WEBWORK_TIMEZONE America/New_York
ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
# temporary state file location. This might be changed to /run in Wheezy+1
ENV APACHE_PID_FILE /var/run/apache2/apache2.pid
ENV APACHE_RUN_DIR /var/run/apache2
ENV APACHE_LOCK_DIR /var/lock/apache2
# Only /var/log/apache2 is handled by /etc/logrotate.d/apache2.
ENV APACHE_LOG_DIR /var/log/apache2
ENV APP_ROOT /opt/webwork
ENV WEBWORK_ROOT $APP_ROOT/webwork2
ENV PG_ROOT $APP_ROOT/pg
ENV DEV 0

ENV PG_BRANCH=rel-PG-2.14 \
WEBWORK_URL=/webwork2 \
WEBWORK_ROOT_URL=http://localhost \
WEBWORK_DB_HOST=db \
WEBWORK_DB_PORT=3306 \
WEBWORK_DB_NAME=webwork \
WEBWORK_DB_USER=webworkWrite \
WEBWORK_DB_PASSWORD=passwordRW \
WEBWORK_SMTP_SERVER=localhost \
[email protected] \
WEBWORK_TIMEZONE=America/New_York \
APACHE_RUN_USER=www-data \
APACHE_RUN_GROUP=www-data \
# temporary state file location. This might be changed to /run in Wheezy+1 \
APACHE_PID_FILE=/var/run/apache2/apache2.pid \
APACHE_RUN_DIR=/var/run/apache2 \
APACHE_LOCK_DIR=/var/lock/apache2 \
# Only /var/log/apache2 is handled by /etc/logrotate.d/apache2.
APACHE_LOG_DIR=/var/log/apache2 \
APP_ROOT=/opt/webwork \
DEV=0

ENV WEBWORK_DB_DSN=DBI:mysql:${WEBWORK_DB_NAME}:${WEBWORK_DB_HOST}:${WEBWORK_DB_PORT} \
WEBWORK_ROOT=$APP_ROOT/webwork2 \
PG_ROOT=$APP_ROOT/pg \
PATH=$PATH:$APP_ROOT/webwork2/bin

RUN apt-get update \
&& apt-get install -y --no-install-recommends --no-install-suggests \
Expand Down Expand Up @@ -78,35 +80,40 @@ RUN apt-get update \

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

COPY VERSION /tmp

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'` \
&& curl -fSL https://github.com/openwebwork/pg/archive/${WEBWORK_VERSION}.tar.gz -o /tmp/${WEBWORK_VERSION}.tar.gz \
&& tar xzf /tmp/${WEBWORK_VERSION}.tar.gz \
&& mv pg-${WEBWORK_VERSION} $APP_ROOT/pg \
&& rm /tmp/${WEBWORK_VERSION}.tar.gz \
# Block to include webwork2 in the container, when needed, instead of getting it from a bind mount.
# Uncomment when needed, and set the correct branch name on the following line.
#ENV WEBWORK_BRANCH=rel-ww2.14 # need a valid branch name from https://github.com/openwebwork/webwork2
#RUN curl -fSL https://github.com/openwebwork/webwork2/archive/${WEBWORK_BRANCH}.tar.gz -o /tmp/${WEBWORK_BRANCH}.tar.gz \
# && cd /tmp \
# && tar xzf /tmp/${WEBWORK_BRANCH}.tar.gz \
# && mv webwork2-${WEBWORK_BRANCH} $APP_ROOT/webwork2 \
# && rm -rf /tmp/${WEBWORK_BRANCH}.tar.gz /tmp/webwork2-${WEBWORK_BRANCH}

RUN curl -fSL https://github.com/openwebwork/pg/archive/${PG_BRANCH}.tar.gz -o /tmp/${PG_BRANCH}.tar.gz \
&& tar xzf /tmp/${PG_BRANCH}.tar.gz \
&& mv pg-${PG_BRANCH} $APP_ROOT/pg \
&& rm /tmp/${PG_BRANCH}.tar.gz \
&& curl -fSL https://github.com/openwebwork/webwork-open-problem-library/archive/master.tar.gz -o /tmp/opl.tar.gz \
&& tar xzf /tmp/opl.tar.gz \
&& mv webwork-open-problem-library-master $APP_ROOT/libraries/webwork-open-problem-library \
&& rm /tmp/opl.tar.gz \
&& curl -fSL https://github.com/mathjax/MathJax/archive/master.tar.gz -o /tmp/mathjax.tar.gz \
&& tar xzf /tmp/mathjax.tar.gz \
&& mv MathJax-master $APP_ROOT/MathJax \
&& rm /tmp/mathjax.tar.gz \
&& rm /tmp/VERSION
#curl -fSL https://github.com/openwebwork/webwork2/archive/WeBWorK-${WEBWORK_VERSION}.tar.gz -o /tmp/WeBWorK-${WEBWORK_VERSION}.tar.gz \
#&& tar xzf /tmp/WeBWorK-${WEBWORK_VERSION}.tar.gz \
#&& mv webwork2-WeBWorK-${WEBWORK_VERSION} $APP_ROOT/webwork2 \
#&& rm /tmp/WeBWorK-${WEBWORK_VERSION}.tar.gz \
&& rm /tmp/mathjax.tar.gz


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

COPY . $APP_ROOT/webwork2

RUN cd $APP_ROOT/webwork2/courses.dist \
&& cp *.lst $APP_ROOT/courses/ \
&& cp -R modelCourse $APP_ROOT/courses/ \
&& cd $APP_ROOT/pg/lib/chromatic \
# Move these lines into docker-entrypoint.sh so the bind mount of courses
# will be available
#RUN cd $APP_ROOT/webwork2/courses.dist \
# && cp *.lst $APP_ROOT/courses/ \
# && cp -R modelCourse $APP_ROOT/courses/

RUN cd $APP_ROOT/pg/lib/chromatic \
&& gcc color.c -o color

# setup apache
Expand Down
1 change: 0 additions & 1 deletion PG_VERSION

This file was deleted.

4 changes: 4 additions & 0 deletions PG_VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
$PG_VERSION ='PG-2.14';
$PG_COPYRIGHT_YEARS = '1996-2018';

1;
4 changes: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ services:
db:
image: mariadb:10.1
volumes:
- "./.data/db:/var/lib/mysql"
- mysql:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: randomepassword
Expand Down Expand Up @@ -31,3 +31,5 @@ services:
image: ubcctlt/rserve
ports:
- "6311:6311"
volumes:
mysql:
27 changes: 27 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,29 @@ if [ "$1" = 'apache2' ]; then
chown www-data:root -R $APP_ROOT/courses
echo "Admin course is created."
fi
# modelCourses link if not existing
if [ ! -d "$APP_ROOT/courses/modelCourse" ]; then
echo "create modelCourse subdirectory"
rm -rf $APP_ROOT/courses/modelCourse
cd $APP_ROOT/webwork2/courses.dist
cp -R modelCourse $APP_ROOT/courses/
fi
# defaultClasslist.lst and adminClasslist.lst files if not existing
if [ ! -f "$APP_ROOT/courses/defaultClasslist.lst" ]; then
echo "defaultClasslist.lst is being created"
cd $APP_ROOT/webwork2/courses.dist
cp *.lst $APP_ROOT/courses/
fi
if [ ! -f "$APP_ROOT/courses/adminClasslist.lst" ]; then
echo "adminClasslist.lst is being created"
cd $APP_ROOT/webwork2/courses.dist
cp *.lst $APP_ROOT/courses/
fi
# run OPL-update if necessary
if [ ! -f "$APP_ROOT/webwork2/htdocs/DATA/tagging-taxonomy.json" ]; then
cd $APP_ROOT/webwork2/bin
./OPL-update
fi
# generate apache2 reload config if needed
if [ $DEV -eq 1 ]; then
echo "PerlModule Apache2::Reload" > /etc/apache2/conf-enabled/apache2-reload.conf
Expand All @@ -45,6 +68,10 @@ if [ "$1" = 'apache2' ]; then
else
rm -f /etc/apache2/conf-enabled/apache2-reload.conf
fi
# Fix possible permission issues
cd $APP_ROOT/webwork2
chown -R www-data logs tmp DATA htdocs/tmp ../courses
chmod -R u+w logs tmp DATA htdocs/tmp ../courses
fi

exec "$@"

0 comments on commit afa47dd

Please sign in to comment.