A Docker-Compose project for running wordpress
Tim Sutton, 2015
In May 2019 I moved the site content to a static site
InaSAFE.org - Static Site
General setup:
Wordpress deployed on the host directly (no docker). Several other sites there :
https://manual.inasafe.org (static) https://docs.inasafe.org (static, deprecated by above)
Nightly and experimental builds disabled
I have Wordpress disabled by default for security. When you want to update the site you need to do these steps:
- Disable static version of the site
- Enable WP version of the site
- Restart Nginx
- Make any needed changes
- Scrape the site using wget
- Disable WP version
- Enable static
- Restart nginx
This is the command to make the mirror
wget --recursive --no-clobber --page-requisites --html-extension --convert-links --restrict-file-names=windows https://inasafe.org
TODO move manual, docs and static site into github pages and shut down this server
I have backups of the WP dump and dynamic site on my personal machines static dir
Original notes for docker based instance now follow:
This is a docker project for running worpress in a clean and persistent way.
It is based on work I did for our kartoza internal web site - and builds on docker images from tutum.
I wanted clean separation between:
- mysql
- wp apache container
And:
- optional mysql file based storage on host volume
- wp-content in host volume
- db password configured at run time using an environment variable when you first spin up an instance
- a way to easily generate a backup or restore a backup of your database
- Edit the top the Make file and change the PROJECT_ID as needed
- Edit the top the Make file and change the PASSWORD as needed
- Optionally, Also edit docker-compose.yml and change the port number for the web service to a port of your choice (default is to run on host port 2080)..
make web
You should have an empty, default installation if wordpress running.
To load an existing site you need:
- Set up a default empty site as described above.
- A recent sql dump of the wordpress database from the site, saved under backups/wordpress.sql
- Optionally the wp-content directory from the original site. The wp-content dir should be unpacked in the root of this repo.
Now restore the backup (your old db will be dropped destroying any old data):
make dbrestore
Most of the point of this project is to have a wordpress site that you can backup and upgrade easily. To do backups you can use these make targets:
make dbbackup
make wpbackup
For nightly backups you can add a line like this to your crontab:
0 22 * * * cd /home/web/inasafe.org && make dbbackup && make wpbackup
- build - builds / fetches docker images
- web - Brings up the site. Mysql data wil be persisted in db folder, wp-content in wp-content folder.
- run - executes build then web targets
- default - alias for web target
- dblogs - tails the logs from teh mysql container
- wplogs - tails the wordpress containers logs
- dbshell - gives you a bash shell in the mysql container
- wpshell - gives you a bash shell in the context of the wp container
- webwithrestore - executes web then dbrestore. This is a shortcut for restoring an existing site.
- dbbackup - perform a backup of the mysql database. Backup placed in /backups//
- dbrestore - perform a restore of the wordpress mysql database. Restore file should exist as backups/wordpress.sql
- wpbackup - performs a backup of the wp-content folder. Backup placed in /backups//
- kill - killas all containers (but does not remove them)
- rm - Implies kill target. Kills then removes all containers