A Docker Compose stack for deploying WordPress using a Traefik proxy.
-
Copy the sample file .env.sample as
.envand fill in the missing information. -
Create the network:
sudo docker network create web
sudo docker network create backend
sudo docker network create socket- Set correct permissions on
acme.jsonfile to allow Traefik to write certificates:
sudo chmod 600 traefik/acme.json- Build the stack:
sudo docker compose build --no-cache- Run the stack:
sudo docker compose up -dCopy and activate the Docker systemd service:
cp infra/systemd/docker-wordpress.service /etc/systemd/system
sudo systemctl daemon-reload
sudo systemctl enable docker-wordpress.service
sudo systemctl start docker-wordpress.service- Generate random salt: https://api.wordpress.org/secret-key/1.1/salt/
- Add values to the
.envfile
WordPress may need FORCE_SSL_ADMIN to properly load stylesheets and force HTTPS in the admin dashboard:
define('FORCE_SSL_ADMIN', true);
// If we're behind a proxy server and using HTTPS, we need to alert WordPress of that fact
// see also https://wordpress.org/support/article/administration-over-ssl/#using-a-reverse-proxy
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false) {
$_SERVER['HTTPS'] = 'on';
}cat /path/to/dump.sql | sudo docker exec -i db mariadb -u root database-name