A blueprint Docker configuration used for WordPress development on Docker.
This is a repository for testing out working with WordPress on Docker. You can use it as a base for your project, to play and to use as you wish.
Development is done locally, using Docker for quick starting the application. In order to start working on the app, once you've cloned the repository locally you should use the make command. This will:
- Copy the
.env.exampleto.env - List all the useful commands you might want to use for kick-starting your project
You'll need to fill the created .env file with the necessary data.
This setup uses locally self signed SSL certificate to make your site run on HTTPS. In order to enable the SSL locally you'll need to set it up first.
Add the value of the APP_HOST variable from the .env file to you hosts file using vim, nano or what ever editor you like. The following is an example how to add it on MacOS using terminal
sudo nano /etc/hostsThen add
0.0.0.0 APP_HOST GOES HEREAnd save it. On Windows, the hosts is located in C:\windows\system32\drivers\etc\hosts.
Generate an openssl key/cert pair from your development folder:
make create-certificateYou will have to fill in the following questions;
* Country Name (2 letter code)
* State or Province Name (full name)
* Locality Name (eg, city)
* Organization Name (eg, company)
* Organizational Unit Name (eg, section)
* Common Name (eg, fully qualified host name) -> APP_HOST
* Email AddressOnce this is done, you should have 2 files in the config/certs folder
APP_HOST.crt
APP_HOST.keyAdd the .crt file to your keychain access and change the Trust settings to Always Trust (on MacOS).
Before starting the docker up, you'll need to copy the wp-config.php.tmpl to wp-config.php, and ngixn.conf.tmpl to ngixn.conf. If you have set up the .env file type
make copy-configsYou can test if everything is set up correctly for your docker-compose.yml with
make docker-configThis will prefill all the values with environment variables from .env file and resolve the paths.
After all has been set up in the environment file run
make docker-buildThis will create the containers for the app. To run them (in a detached state) you need to type
make docker-upSome settings like nginx.conf and php.ini (especially the opcache settings) need to be modified for production. You should coordinate with your devops when working on production environment.
You can add additional services in your docker-compose.yml if you want to. The .env.example contains the environment variables for redis and mailhog services. To use them, add them to your docker-compose.yml file under services like
redis:
image: redis
container_name: ${REDIS_CONTAINER_NAME}
environment:
REDIS_SCHEME: ${REDIS_SCHEME}
REDIS_HOST: ${REDIS_HOST}
REDIS_PORT: ${REDIS_PORT}
expose:
- ${REDIS_PORT}
ports:
- ${REDIS_PORT}:${REDIS_PORT}
mailhog:
image: mailhog/mailhog
container_name: docker-mailhog
ports:
- "${MAILHOG_HOST_PORT_SMTP}:1025"
- "${MAILHOG_HOST_PORT_WEB}:8025"WordPress on Docker is free software, and may be redistributed under the terms specified in the LICENSE file. Copyright ©2019