From 5e391c99f1d51e74ef715dd4039a81d6f2b80894 Mon Sep 17 00:00:00 2001 From: Michael Gage Date: Fri, 2 Jul 2021 12:55:01 -0400 Subject: [PATCH 01/17] Commit changes that change owner of htdocs/tmp to www-data and the sed line which enables Rserve in localOverrides.conf --- docker-compose.yml | 4 ++-- docker-config/docker-entrypoint.sh | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 8acac6cf91..09008f0865 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -88,7 +88,7 @@ services: - PG_BRANCH=PG-2.16 # If you are using the 2 stage build process uncomment the next line - #dockerfile: DockerfileStage2 + dockerfile: DockerfileStage2 # and first run # docker build --tag webwork-base:forWW216 -f DockerfileStage1 . # and then @@ -225,7 +225,7 @@ services: #ADD_LOCALES: "he_IL ISO-8859-8\nhe_IL.UTF-8 UTF-8\n" # Extra Ubuntu packages to install during startup - #ADD_APT_PACKAGES: vim telnet + ADD_APT_PACKAGES: vim less # The system timezone for the container can be set using #SYSTEM_TIMEZONE: zone/city diff --git a/docker-config/docker-entrypoint.sh b/docker-config/docker-entrypoint.sh index a63628fa94..78a5c00e0e 100755 --- a/docker-config/docker-entrypoint.sh +++ b/docker-config/docker-entrypoint.sh @@ -85,7 +85,14 @@ if [ "$1" = 'apache2' ]; then -e 's/^# $server_groupID = '\''www-data/$server_groupID = '\''www-data/' \ $WEBWORK_ROOT/conf/site.conf fi + + if [ $i == 'localOverrides.conf' ]; then + sed -i \ + -e 's/# $pg{specialPGEnvironmentVars}{Rserve} = {host => "r"};/$pg{specialPGEnvironmentVars}{Rserve} = {host => "r"};/' \ + $WEBWORK_ROOT/conf/localOverrides.conf + fi fi + done # create admin course if not existing if [ ! -d "$APP_ROOT/courses/admin" ]; then @@ -208,8 +215,11 @@ if [ "$1" = 'apache2' ]; then # This change significantly speeds up Docker startup time on production # servers with many files/courses (on Linux). - chown -R www-data:www-data logs tmp DATA - chmod -R ug+w logs tmp DATA + + chown -R www-data:www-data logs tmp DATA + chmod -R ug+w logs tmp DATA + chown www-data:www-data htdocs/tmp + chmod ug+w htdocs/tmp # Symbolic links which have no target outside the Docker container # cause problems duringt the rebuild process on some systems. From d741ec9a4edf1a8e4850673524233a56f3ee9d82 Mon Sep 17 00:00:00 2001 From: Michael Gage Date: Fri, 2 Jul 2021 13:09:26 -0400 Subject: [PATCH 02/17] insure that that admin course tables are up to date even if the current admin directory already exists. make sure that a default admin user with admin password is enrolled in the course and echo that fact to the installer of the WW docker box. update README --- README | 3 ++- docker-config/docker-entrypoint.sh | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README b/README index 5994eb525b..e5f5f5c736 100644 --- a/README +++ b/README @@ -4,7 +4,8 @@ Branch: github.com/openwebwork http://webwork.maa.org/wiki/Release_notes_for_WeBWorK_2.16 - Copyright 2000-2019, The WeBWorK Project + Copyright 2000-2021, The WeBWorK Project + http://webwork.maa.org All rights reserved. diff --git a/docker-config/docker-entrypoint.sh b/docker-config/docker-entrypoint.sh index 78a5c00e0e..0d40ab99c1 100755 --- a/docker-config/docker-entrypoint.sh +++ b/docker-config/docker-entrypoint.sh @@ -103,6 +103,9 @@ if [ "$1" = 'apache2' ]; then $WEBWORK_ROOT/bin/addcourse admin --db-layout=sql_single --users=$WEBWORK_ROOT/courses.dist/adminClasslist.lst --professors=admin chown www-data:www-data -R $APP_ROOT/courses echo "Admin course is created." + $WEBWORK_ROOT/bin/upgrade_admin_db.pl + $WEBWORK_ROOT/wwsh admin ./addadmin + echo "user: admin password: admin added to course admin and tables upgraded" fi # modelCourses link if not existing if [ ! -d "$APP_ROOT/courses/modelCourse" ]; then From 9de71021232c372f7883a961cd0dc0860b6f4fcd Mon Sep 17 00:00:00 2001 From: Michael Gage Date: Fri, 2 Jul 2021 13:18:12 -0400 Subject: [PATCH 03/17] Add folder for docker set up instructions --- ...WorKDocker instructions for development.md | 169 ++++++++++++++++++ .../WeBWorKDocker startup instructions.md | 123 +++++++++++++ 2 files changed, 292 insertions(+) create mode 100644 Instructions for installing with Docker/WeBWorKDocker instructions for development.md create mode 100644 Instructions for installing with Docker/WeBWorKDocker startup instructions.md diff --git a/Instructions for installing with Docker/WeBWorKDocker instructions for development.md b/Instructions for installing with Docker/WeBWorKDocker instructions for development.md new file mode 100644 index 0000000000..e787a27a12 --- /dev/null +++ b/Instructions for installing with Docker/WeBWorKDocker instructions for development.md @@ -0,0 +1,169 @@ + + +## WeBWorK/Docker instructions for development + + + +* Docker must be installed on your machine + + * https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-compose-on-ubuntu-20-04 + * docker-compose --ver: version 1.25.0 + +* create a directory to work in `webwork-docker` + +* `cd webwork-docker` + +* obtain the webwork repositories + + * front end (webwork2) `git clone https://github.com/openwebwork/pg` + * problem rendering code (pg)`git clone https://github.com/openwebwork/pg` + * problem library (OPL) `git clone https://github.com/openwebwork/webwork-open-problem-library` + +* get the appropriate versions of the code. At the moment (6/16/2021) the default download is the 'master' branch which has version 2.15. The current version is 2.16 which you will need for installing webwork in docker following these instructions + + * `cd webwork2` + + * `git branch -a` displays all the branches, (-a includes the remote branches) + * `git checkout WeBWorK-2.16` (makes a local version of the WeBWorK-2.16 branch -- there are some defaults involved -- the command automatically assumes that you want to copy from origin/WeBWorK-2.16) (for now pull from mgage/) + * `git branch` check that things worked: you should see * WeBWorK-2.16 (or ww216_patches_quotes) + * cd .. + +* webwork-open-problem-library usually only has the master branch so the clone operation has already downloaded the current version + +* set configuration in docker documents + + * `cd webwork2` + + * vim docker-compose.yml + + * in the file webwork2/docker-compose.yml change the line `WEBWORK_ROOT_PASSWORD=passwordRWsetItBeforeFirstStartingTheDBcontainer` replacing `passwordRWset...` with a reasonable password to be used for `root` access the mariaDB database. + * This password should be set before you do your first build (which is the only time the database is created). Successive builds use the database that has already been created, unless you explicitly remove that volume + + * vim .env + + * in the file webwork2/.env change the line `WEBWORK_DB_PASSWORD=passwordRWsetItBeforeFirstStartingTheDBcontainer` replacing `passwordRWset...`with a reasonable password to be used for `webworkWrite` to access the mariaDB database. + * the other variables can be left with the defaults + + + * sanity checks: + + * git branch should return WeBWorK-2.16 + * git status should show that the files `webwork2/.env` and `webwork2/docker-compose.yml` have been modified + * `git diff .env` should show only the new password has been changed + * `git diff docker-compose.yml` should show that only the new password has been changed. + * did you change the database passwords for root and for webworkWrite in the files `webwork2/docker-compose.yml` and in `.env` + + * we're ready to build + + * make sure you are in the `webwork2` directory + * type `docker build --tag webwork-base:forWW216 -f DockerfileStage1 .` + * wait -- and watch the messages fly by. + * This builds the underlying unix layer of the WeBWorK stack + *stage2 + make sure that the line `dockerfile: DockerfileStage2` is uncommented (careful there is also an empty `dockerfile:` line -- ignore it) + * type `docker-compose build` + * watch more lines fly by. + * hopefully this build ends without errors + * final stage + * type `docker-compose up` + * watch more lines fly by + * a successful build ends with + ``` + --- webwork.maa.org ping statistics --- + app_1 | 1 packets transmitted, 1 received, 0% packet loss, time 0ms + app_1 | rtt min/avg/max/mdev = 21.580/21.580/21.580/0.000 ms + ``` + ------ + +* or something similar + +* do not close the terminal window! + +* start your browser to point at `localhost:8080/webwork` + +* click on Course Administration + +* login with `username admin` `password admin` + +* Congratulations you are now the administrator of your own private WeBWorK site! + +* you can turn your site off by pressing ^C in the terminal window or executing `docker-compose down` in another terminal window + +* to restart your site type: `docker-compose up -d` the `-d` (for detach) puts the site execution in the background and returns the terminal window to the focus of your keyboard. It also suppresses all of the reporting lines about the build. The (re-)build will be much faster since most of the work has been cached. + +* you can turn the site off with `docker-compose down` + +* as long as your docker application remains running (and you don't explicitly delete things) the status of your site, including courses created, problems created and assigned, etc., will be preserved from one `docker-compose down` to the next `docker-compose up`. + +* docker-compose build (may not work) + + docker-compose up (more likely to work) + + direct your browser to localhost:8080 + + + +* successfully tagged webwork: latest + +* successfully built ######### + +* debugging notes: + + * if admin course is not working you may need to fix it from inside the container using webwork2/bin/addcourse admin + +Font Awesome Free 5.15.2 by @fontawesome - https://fontawesome.com +License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) + +added 8 packages from 928 contributors and audited 8 packages in 1.482s + +1 package is looking for funding + run `npm fund` for details + +found 0 vulnerabilities + + + +``` +Table 'webwork.OPL_local_statistics' doesn't exist at /opt/webwork/webwork2/lib/WeBWorK/Utils/LibraryStats.pm line 71. +``` + +Loading failed for the