Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
5e391c9
Commit changes that change owner of htdocs/tmp to www-data and the s…
mgage Jul 2, 2021
d741ec9
insure that that admin course tables are up to date even if the curre…
mgage Jul 2, 2021
9de7102
Add folder for docker set up instructions
mgage Jul 2, 2021
f99322c
Make sure the admin course is owned by www-data. Even if it is a res…
mgage Jul 2, 2021
ed24ff7
sed seemed to be having a hard time with line breaks. eliminating th…
mgage Jul 2, 2021
4e037db
install instructions still need more work
mgage Jul 2, 2021
77c05ae
Check explicitly to see if the admin_user table exists and if not upg…
mgage Jul 5, 2021
5b2e3ad
Temporarily remove check admin tables feature to force docker to compile
mgage Jul 5, 2021
c45e954
Add -h db flag to mysql command so that it will work in the container…
mgage Jul 5, 2021
0154021
Removing install instructions
mgage Jul 5, 2021
5c60fe1
we decided to check whether the admin tables existed from within the …
mgage Jul 5, 2021
895ccd3
latest attempt to recover admin tables if they are missing
mgage Jul 5, 2021
6fc9c2c
incorporate suggestions from @tani
mgage Jul 6, 2021
fd87dbf
turn showLibraryLocalStats off, remove extraneous repeated line
mgage Jul 6, 2021
529297a
replace vim with nano for included editor
mgage Jul 7, 2021
e57d5d2
fix editing of showLibraryLocalStats flag, fixed ELIF conditional to…
mgage Jul 7, 2021
7e2a3bc
Move mysql root password to .env. Add .env to .gitignore so only updated
taniwallach Jul 7, 2021
6cfa7bf
Merge pull request #36 from taniwallach/docker-move-mysql-root-password
mgage Jul 7, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ COURSES_DIRECTORY_ON_HOST=../ww-docker-data/courses
WEBWORK2_HTTP_PORT_ON_HOST=8080
WEBWORK_DB_USER=webworkWrite
WEBWORK_DB_PASSWORD=passwordRWsetItBeforeFirstStartingTheDBcontainer
WEBWORK_MYSQL_ROOT_PASSWORD=sqlRootPasswordSetThisPasswordBEFOREfirstStartingTheDBcontainer
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*.conf
*-config
.env
applets
tmp
logs
Expand Down
3 changes: 2 additions & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -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.

6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ services:
# When the MariaDB container is first started it will set the
# the MYSQL_ROOT_PASSWORD if there is no mysql database in the
# data volume.
MYSQL_ROOT_PASSWORD: sqlRootPasswordSetThisPasswordBEFOREfirstStartingTheDBcontainer
MYSQL_ROOT_PASSWORD: ${WEBWORK_MYSQL_ROOT_PASSWORD}

# When the MariaDB container is first started it will create
# the WW database and WW DB user based on:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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: nano less

# The system timezone for the container can be set using
#SYSTEM_TIMEZONE: zone/city
Expand Down
51 changes: 45 additions & 6 deletions docker-config/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,24 +79,57 @@ if [ "$1" = 'apache2' ]; then
-e 's/^\$database_username ="webworkWrite"/$database_username =$ENV{"WEBWORK_DB_USER"}/' \
-e 's/^\$database_password ='\''passwordRW'\''/$database_password =$ENV{"WEBWORK_DB_PASSWORD"}/' \
-e 's/mail{smtpServer} = '\'''\''/mail{smtpServer} = $ENV{"WEBWORK_SMTP_SERVER"}/' \
-e 's/mail{smtpSender} = '\'''\''/mail{smtpSender} = $ENV{"WEBWORK_SMTP_SENDER"}/' \
-e 's/siteDefaults{timezone} = "America\/New_York"/siteDefaults{timezone} = $ENV{"WEBWORK_TIMEZONE"}/' \
-e 's/^# $server_userID = '\''www-data/$server_userID = '\''www-data/' \
-e 's/^# $server_groupID = '\''www-data/$server_groupID = '\''www-data/' \
$WEBWORK_ROOT/conf/site.conf
-e 's/^# $server_groupID = '\''www-data/$server_groupID = '\''www-data/' $WEBWORK_ROOT/conf/site.conf

echo "$WEBWORK_ROOT/conf/$i has been modified."
fi

if [ $i == 'localOverrides.conf' ]; then
sed -i -e 's/#$pg{specialPGEnvironmentVars}{Rserve} = {host => "r"};/$pg{specialPGEnvironmentVars}{Rserve} = {host => "r"};/' \
-e 's/#$problemLibrary{showLibraryLocalStats} = 0;/$problemLibrary{showLibraryLocalStats} = 0;/' $WEBWORK_ROOT/conf/localOverrides.conf
echo "$WEBWORK_ROOT/conf/$i has been modified."
fi
fi

done
# create admin course if not existing
if [ ! -d "$APP_ROOT/courses/admin" ]; then
# check first if the admin courses directory exists then check that at
# least one of the tables associated with the course (the admin_user table) exists

echo "check admin course and admin tables"
wait_for_db
ADMIN_TABLE_EXISTS=`mysql -u $WEBWORK_DB_USER -p$WEBWORK_DB_PASSWORD -B -N -h db -e "select count(*) from information_schema.tables where table_schema='webwork' and table_name = 'admin_user';" 2>/dev/null`

if [ ! -d "$APP_ROOT/courses/admin" ]; then
newgrp www-data
umask 2
cd $APP_ROOT/courses
wait_for_db
$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."
echo "user: admin password: admin added to course admin and tables upgraded"
elif [ $ADMIN_TABLE_EXISTS == 0 ]; then
echo "admin course db tables need updating"
$WEBWORK_ROOT/bin/upgrade_admin_db.pl
$WEBWORK_ROOT/bin/wwsh admin $WEBWORK_ROOT/bin/addadmin
echo "admin course tables created with one user: admin whose password is admin"
else
echo "using pre-existing admin course and admin tables"
fi

# use case for the extra check for the admin:
# In rebuilding a docker box one might clear out the docker containers,
# images and volumes including mariaDB, BUT leave the
# contents of ww-docker-data directory in place. It now holds the shell of the courses
# including the admin course directory. This means that once you rebuild the box
# you can't access the admin course (because the admin_user table is missing)
# and you need to run bin/upgrade_admin_db.pl from inside the container.
# This check insures that if the admin_user table is missing the whole admin course is rebuilt
# even if the admin directory is in place.

# modelCourses link if not existing
if [ ! -d "$APP_ROOT/courses/modelCourse" ]; then
echo "create modelCourse subdirectory"
Expand Down Expand Up @@ -208,8 +241,14 @@ 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

# even if the admin and courses directories already existed their permissions might not have been correct
# chown www-data:www-data $APP_ROOT/courses
chown www-data:www-data $APP_ROOT/courses/admin/*

# Symbolic links which have no target outside the Docker container
# cause problems duringt the rebuild process on some systems.
Expand Down