Generic mechanism for moving Wordpress sites to Docker
Concept
Based on a wordpress site backup (config file, data dump, wp-content directory), a Docker container is created and started. This container also provides a daily backup of the same files
Implementation
In the /export volume, Docker will find the wp-content directory and SQL dump named wordpress.sql
Before copying these files over (and doing a DB dump), all themes, plugins & wordpress itself should be up to data (latest WP is mandatory).
At container creation, once wordpress & dependencies are installed, the following should happen:
Database is created
MySQL dump is loaded
The wp-content directory is copied over (then the nginx plugin is installed)
The wordpress nstance is brought up
Naming convention
config file will be called wp-config.php and found at the root
Database dump will be called wordpress.sql and found at the root
Wordpress content directory will be called wp-content and found at the root
Of note
the database will be called wordpress, make sure the DB dump doesn't use another database (nor does it create one)
I'll need help from the community to make this as generic as possible
The core of this project is a 'fork' from https://github.com/eugeneware/docker-wordpress-nginx
Usage
Create the image:
docker build -t "move-wordpress-to-docker" --no-cache .
Copy
Examples for creating & running the container:
docker run -p 80:80 -v ~/absolute-path-to-the-export-directory/thecloudsaga:/export --name thecloudsaga -d move-wordpress-to-docker
Copy
Note the mysql password & the WP password in the container log (i.e. write it down)
TODO
Do we really need wp-config.php ?
Doing away with accepting it as input for now
Can this be supplemental to https://github.com/eugeneware/docker-wordpress-nginx instead of modifying it?
Rely on exported volumes for wp-content backup
Create daily backup on exported volume or let people backup by accessing MySQL on 3306
Figure out how to deploy many of these containers for a multi-host setup (nginx-proxy?)
Remove debugging info
Limitations
If you have a customized wp-config.php file, this application doesn't take that into account
This uses wordpress latest as of 10/14/2015. It would I imagine need to be updated for each new version if you're going to use the image