Set up the database according to https://docs.moodle.org/31/en/PostgreSQL
Moodle automatically checks for upgrades and informs users of available upgrades on the website.
To upgrade:
- Backup files
ubuntu@dokku6:~$ sudo tar -czf moodle_files_2017-01-24.tgz /var/moodle
robin:~$ scp ubuntu@dokku6.code4sa.org:moodle_files_2017-01-24.tgz .
- Upload the backup to Google Drive
- Backup the database
- Our database is snapshotted nightly but it's nice to have an easy-to-restore copy at hand during an upgrade to minimise effort and downtime.
- Note moodle uses hundreds of tables and indices - it will take over 10 minutes for it to even start outputting data. Wait. Relax. Go get some coffee. Keep an eye on it. Check that it's all ok at the end.
pg_dump "postgres://moodle:...@postgresql94-prod.cnc362bhpvfe.eu-west-1.rds.amazonaws.com/moodle" -O -c --if-exists|gzip > prod_2017-01-24.sql.gz
- Rebuild the base docker image which will download the latest minor version of the major version currently selected by Dockerfile-base.
- Pull the latest base image on the app server
ubuntu@dokku6:~$ docker pull code4sa/moodle-base:latest
- Rebuild the app image on the app server
ubuntu@dokku6:~$ dokku ps:rebuild moodle
- Visit the site, login as Admin, follow the database upgrade instructions
- Check that everything looks ok.
This image is usually built by docker hub and pulled by the dokku host. You don't usually need to build it yourself.
docker build -t code4sa/moodle-base:latest -f Dockerfile-base .
docker build -t code4sa/moodle-dokku:latest -f Dockerfile --build-arg NEWRELIC_KEY=... .
docker run -i --net=host -v `pwd`/moodledata:/var/moodledata --name=moodle code4s/moodle-dokku:latest
docker start -i moodle
Visit it at http://localhost/
Moodle is deployed to dokku using "Dockerfile deployment". As usual, we push this repository to dokku. Dokku will see the Dockerfile and build it to create the app image and start the container as usual. This Dockerfile depends on a base image code4sa/moodle-base which we usually build on Docker Hub.
Add remote to your local repo
git remote add dokku dokku@dokku6.code4sa.org:moodle
Configure environment variables and options on server, replacing ... with appropriate values
dokku config:set moodle \
DB_HOST=postgresql94-prod.cnc362bhpvfe.eu-west-1.rds.amazonaws.com \
DB_NAME=moodle \
DB_USER=moodle \
DB_PASSWORD=... \
MOODLE_URL=https://learn.code4sa.org
dokku docker-options:add moodle build,run,deploy "-v /var/log/moodle/apache2:/var/log/apache2"
dokku docker-options:add moodle build,run,deploy "-v /var/moodle/:/var/moodledata"
dokku docker-options:add moodle build "--build-arg NEWRELIC_KEY=..."
dokku proxy:ports-add moodle http:80:80
If the base image has been updated, ensure the latest image is on the host
ubuntu@dokku6:~$ docker pull code4sa/moodle-base:latest
Push any config/dockerfile updates to dokku. Dokku will build an image based on Dockerfile.
git push dokku master
*/1 * * * * dokku --rm run moodle /usr/bin/php /var/www/html/admin/cli/cron.php > /dev/null