- latest alpine based php version with enabled opcache
- can be used as a template for WP project: just fork, change configs, setup volume for mysql
- prepared for containerized deployments: just extend docker image with your own using as example
wp-app
dockerfile, inject there plugins. statics
You can use the whole project as a template. Adjust all the configs according to your needs.
Many things are extracted into variables, so that you just have to define variables. Configs can be also easily injected during instance creation.
##Note
if you use provided base image, then it's enough to use docker-compose file content and put own configs
Example of the Dockerfile
for your wordpress application you can find in the ./docker/php/app/Dockerfile.dist
.
cp ./docker/php/app/Dockerfile.dist ./docker/php/app/Dockerfile
Adjust it for your needs.
How to use it you can find out in the docker-compose.yml
: search for the wp-app
application definition.
Variables are extracted into .env
file. Example of this file you can find in the .env.dist
.
cp ./.env.dist ./.env
Adjust this env file with your passwords, tokens, hosts, etc.
Also, using env file you can inject wordpress config constants. Available wordpress constants are:
DB_NAME
DB_USER
DB_PASSWORD
DB_HOST
DB_CHARSET
DB_COLLATE
AUTH_KEY
SECURE_AUTH_KEY
LOGGED_IN_KEY
NONCE_KEY
AUTH_SALT
SECURE_AUTH_SALT
LOGGED_IN_SALT
NONCE_SALT
WP_DEBUG
ABSPATH
WP_TABLE_PREFIX
Also, on the top of it, if some your plugins require additional defined constants you can inject any environmental
variable with prefix WP_
.
You have to adjust my default configuration with your own. Probably, you would want to define error reporting level, set up more caching, ssl certificates, etc...
By default, host is wordpress.loc
.
You also must create a volume for mysql, otherwise you gonna loose all the data right after instance termination.
Do not forget to tune up mysql to get maximum of performance.
There are many different ways how to handle static. One of them: you can put all of them into the WP application. In this case you would have only one image, which is contain all the stuff. Negative side is that docker image can be huge.
Another way is to use assets volume and put uploads into the assets volume.
Whatever way you would choose, you need to track files with any cvs
(for example, git).
You can make automated builds, just set up docker images auto-build on each push in repo. Make automated push when filesystem change for static assets is detected. In this case your image would always contain the latest data.
docker-compose.yml
is just an example and must be modified according to your needs and security.
- checkout your feature branch from the appropriate one
- make sure that you have the latest changes from remote repository
- make all the changes, create pull request, once it get merged, container would be re-deployed automatically
docker-compose build wp-base
#or less recommended
cd ./docker/php/base/
docker build \
--build-arg WP_VERSION=4.6.8 \
--build-arg BASE_IMG=oleksiichernomaz/php-fpm:7.2 \
--compress --pull --force-rm \
--tag oleksiichernomaz/wordpress:4.9.8 .
docker run -it oleksiichernomaz/wordpress:4.9.8 php -v