This project has the goal to make it easier to use develop and deploy Wordpress projects while using Docker and Git.
It's very much work in progress, if you have suggestions we encourage you to contribute with a PR.
This project was tested on a Linux environment. The following tools are required:
- Docker CE (latest)
- Docker Compose (latest)
- mysqldump
-
Download a copy of this project setup from
https://github.com/Novadart/dogipress/archive/master.zip
-
Remove the files/directories that will not belong to your project:
- README.md
- .git/
-
Configuration:
A. If you plan to save everything (Wordpress files, database, uploads directory) in git you don't need to configure anything.
B. If you plan to NOT save the database and/or the uploads files in git you need to:
- create a file
local.env
usinglocal.env.template
as template and modify it to point to the directory where you keep thewp-content/uploads
files - open
docker-compose.yml
and uncomment the linethis way during development the files will be sourced from that directory- ${WP_UPLOADS_DIR}:/var/www/html/wp-content/uploads
- add
db/
to.gitignore
NOTE: you can add custom php options in
config/php.ini
. You might need to install custom php extensions, to do so check Dockerfile and the official PHP docker image docs https://store.docker.com/images/php?tab=description - create a file
-
[Only once] Generate the wordpress files by opening a console and running (it will ask you the password):
$ ./start.sh
Open another console and run:
$ ./stop.sh
Then repeat start/stop again, to make sure that the permissions are correctly set.
This will create the files, save a copy of the db and fix permissions to your user.
-
Commit and push the stub of your website to your repo
- [OPTIONAL] If you are working on an existing website you will need to place a copy of the DB in
./db
(make sure that the directory contains only 1 SQL file, since MariaDB will execute all of them) and place the content ofwp-content/uploads
in the directory you defined inlocal.env
- Execute:
./start.sh
- Make changes to your Wordpress site
- Execute:
./stop.sh
- Commit and push changes to your git repo
NOTE: if you chose not to save the DB and/or the uploads directory content on GIT, remember to save them manually somewhere.
-
Build your image
docker build -t my-website:1.2.3 .
-
Manually upload your image on your deployment server
- Save the image
docker save -o /tmp/my-website-1.2.3.tar my-website:1.2.3
- Upload it to the server via FTP
- Log-in on the deployment server and load the image
docker load -i my-website-1.2.3.tar
-
Deploy it using either a custom
docker-compose.yml
or by manually runningdocker run
.
NOTE: unless your site is static and using an external DB, you will need to set the volumes for your uploads folder and the database data.