-
-
Save nmoller/81bd8e149e6aa2a7cf051e0bf248b2e2 to your computer and use it in GitHub Desktop.
FROM alpine/git AS base | |
WORKDIR /opt/base | |
RUN git clone --single-branch --branch master --depth 1 https://github.com/openwebwork/webwork2.git | |
RUN git clone --single-branch --branch master --depth 1 https://github.com/openwebwork/pg.git | |
RUN git clone --single-branch --branch master --depth 1 https://github.com/mathjax/MathJax | |
RUN git clone --single-branch --branch master --depth 1 https://github.com/openwebwork/webwork-open-problem-library | |
# Clean up | |
RUN rm -rf webwork2/.git pg/.git MathJax/.git webwork-open-problem-library/.git && \ | |
rm -rf webwork2/{*ignore,Dockerfile,docker-compose.yml} | |
FROM ubuntu:16.04 | |
ENV PG_BRANCH=master \ | |
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 \ | |
WEBWORK_SMTP_SENDER=webwork@example.com \ | |
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 \ | |
apache2 \ | |
curl \ | |
dvipng \ | |
gcc \ | |
libapache2-request-perl \ | |
libcrypt-ssleay-perl \ | |
libdatetime-perl \ | |
libdancer-perl \ | |
libdancer-plugin-database-perl \ | |
libdbd-mysql-perl \ | |
libemail-address-perl \ | |
libexception-class-perl \ | |
libextutils-xsbuilder-perl \ | |
libfile-find-rule-perl-perl \ | |
libgd-perl \ | |
libhtml-scrubber-perl \ | |
libjson-perl \ | |
liblocale-maketext-lexicon-perl \ | |
libmail-sender-perl \ | |
libmime-tools-perl \ | |
libnet-ip-perl \ | |
libnet-ldap-perl \ | |
libnet-oauth-perl \ | |
libossp-uuid-perl \ | |
libpadwalker-perl \ | |
libpath-class-perl \ | |
libphp-serialization-perl \ | |
libsoap-lite-perl \ | |
libsql-abstract-perl \ | |
libstring-shellquote-perl \ | |
libtemplate-perl \ | |
libtext-csv-perl \ | |
libtimedate-perl \ | |
libuuid-tiny-perl \ | |
libxml-parser-perl \ | |
libxml-writer-perl \ | |
libapache2-reload-perl \ | |
make \ | |
netpbm \ | |
preview-latex-style \ | |
texlive \ | |
texlive-latex-extra \ | |
libc6-dev \ | |
git \ | |
mysql-client \ | |
&& curl -Lk https://cpanmin.us | perl - App::cpanminus \ | |
&& cpanm install --notest XML::Parser::EasyTree Iterator Iterator::Util Pod::WSDL Array::Utils HTML::Template XMLRPC::Lite Mail::Sender Email::Sender::Simple Data::Dump Statistics::R::IO | |
RUN rm -fr /var/lib/apt/lists/* /root/.cpanm | |
RUN mkdir -p $APP_ROOT/courses $APP_ROOT/libraries $APP_ROOT/webwork2 | |
COPY --from=base /opt/base/webwork2 $APP_ROOT/webwork2 | |
COPY --from=base /opt/base/pg $APP_ROOT/pg | |
COPY --from=base /opt/base/webwork-open-problem-library $APP_ROOT/libraries/webwork-open-problem-library | |
COPY --from=base /opt/base/MathJax $APP_ROOT/MathJax | |
RUN echo "PATH=$PATH:$APP_ROOT/webwork2/bin" >> /root/.bashrc | |
RUN cd $APP_ROOT/pg/lib/chromatic \ | |
&& gcc color.c -o color | |
# setup apache | |
RUN cd $APP_ROOT/webwork2/conf \ | |
&& cp webwork.apache2.4-config.dist webwork.apache2.4-config \ | |
&& cp $APP_ROOT/webwork2/conf/webwork.apache2.4-config /etc/apache2/conf-enabled/webwork.conf \ | |
&& a2dismod mpm_event \ | |
&& a2enmod mpm_prefork \ | |
&& sed -i -e 's/Timeout 300/Timeout 1200/' /etc/apache2/apache2.conf \ | |
&& sed -i -e 's/MaxRequestWorkers 150/MaxRequestWorkers 20/' \ | |
-e 's/MaxConnectionsPerChild 0/MaxConnectionsPerChild 100/' \ | |
/etc/apache2/mods-available/mpm_prefork.conf \ | |
&& cp $APP_ROOT/webwork2/htdocs/favicon.ico /var/www/html \ | |
&& sed -i -e 's/^<Perl>$/\ | |
PerlPassEnv WEBWORK_URL\n\ | |
PerlPassEnv WEBWORK_ROOT_URL\n\ | |
PerlPassEnv WEBWORK_DB_DSN\n\ | |
PerlPassEnv WEBWORK_DB_USER\n\ | |
PerlPassEnv WEBWORK_DB_PASSWORD\n\ | |
PerlPassEnv WEBWORK_SMTP_SERVER\n\ | |
PerlPassEnv WEBWORK_SMTP_SENDER\n\ | |
PerlPassEnv WEBWORK_TIMEZONE\n\ | |
\n<Perl>/' /etc/apache2/conf-enabled/webwork.conf | |
RUN cd $APP_ROOT/webwork2/ \ | |
&& chown www-data DATA ../courses htdocs/tmp htdocs/applets logs tmp $APP_ROOT/pg/lib/chromatic \ | |
&& chmod -R u+w DATA ../courses htdocs/tmp htdocs/applets logs tmp $APP_ROOT/pg/lib/chromatic | |
COPY --from=base /opt/base/webwork2/docker-entrypoint.sh /usr/local/bin/ | |
ENTRYPOINT ["docker-entrypoint.sh"] | |
EXPOSE 80 | |
WORKDIR $APP_ROOT | |
CMD ["apache2", "-DFOREGROUND"] |
@mgage
I did not change anything from the main version (well only how to get the components with a multistage build).
The docker-compose with the app volumes for development (of webwork or pg as seemed to be the need for Florian... if he is working there, he can uncomment the current docker-compose.yml to use that option) .
As you can see with this setup... you can chose the branch needed for each one of your components. I usually prefer to go with an image instead of going with the build statement in the docker-compose file while I'm in dev.
To clarify, what I do is comment out the build statement and before starting I do
docker build -t webwork .
to have a local webwork image.
Mike, as you see with this strategy is quite easy to switch branches if you want a full image.
But it does not seem to be the point here, it seems that what most people want is an image to get their development going.
I still have a lot to learn about docker. I think I follow what you are doing but I'm getting the following error -- which I think means something about the way the database was set up isn't right. I'm using the docker compose and entry point files from mgage/multilingual
ERROR: for webwork_docker_nmoller_db_1 Cannot start service db: b'OCI runtime create failed: container_linux.go:344: starting container process caused "process_linux.go:424: container init caused \"rootfs_linux.go:58: mounting \\\"/Users/mgage/webwork/webwork_docker_nmoller/docker-config/db/mariadb.cnf\\\" to rootfs \\\"/var/lib/docker/overlay2/95a9985df5a14461a261d242bec6c312633bd703b08f24ba8b6059214787f4e7/merged\\\" at \\\"/var/lib/docker/overlay2/95a9985df5a14461a261d242bec6c312633bd703b08f24ba8b6059214787f4e7/merged/etc/mysql/conf.d/mariadb.cnf\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type'
Is this gist file meant to supplement a larger repository on your site somewhere? or repository at github.com/openwebwork?
I'm building within docker on a macOS machine if that makes a difference.
It seems to be a problem with a volume mounted in the db. Surely you have modified the config of maria to get some encoding and it does not found it. Are you missing some folder in a new clonning place?
The gist I've shared is supposed to be used instead of the Dockerfile in the webwork2 repository. I've replaced it and I can run. As your multi-stage build has worked.... it is not an issue of your docker version.
docker-config/db/mariadb.cnf
was added in the multilingual support PR branch under webwork2
to force the MariaDB into utf8mb4
and is mounted into the MariaDB image via docker-compose.yml
. It is quite possible that the relevant directory needs to be copied into /Users/mgage/webwork/webwork_docker_nmoller/
if that is where you are now running docker-compose up
to get it to work.
Hi Nelson,
Thanks very much for this.
The build works perfectly (so far). Can we include the docker-compose.yml files and the docker-entrypoint.sh
with this? I'd be happy to put something like a
webwork_docker
repos up on github.com/openwebwork so thatpeople can try it out. As a separate repos we could also add other branches if others have tweaks they would like to propose.
Did you have your own version of the docker-compose and docker-entrypoint files or were you using the ones we already have in develop or the multilingual pull request?
-- Mike