Template for deploying WordPress in a Docker Swarm environment using:
- 🐳 Docker Swarm
- ⚙️ GitHub Actions (CI/CD)
- 🔐 Secrets-based image builds and secure SSH deployment
- 🌐 NGINX Proxy Manager
- 🛠 MariaDB (shared container or RDS)
- 🧩 Auto WordPress install + plugin setup
docker-compose.ymlfor Swarm-based deploymentwordpress/Dockerfileto extendwordpress:php8.4-fpmwith:- SSH access
- WP-CLI
- Auto plugin install
- GitHub Actions workflow to:
- Build Docker image
- Push to GitHub Container Registry (GHCR)
- Organizational secret required
- SWARM_HOST
- SWARM_USER
- SSH_PRIVATE_KEY
- Organizational secret required
- Deploy to your Swarm node via SSH
entrypoint.shto initialize WordPress and install core plugins
- Docker Swarm with at least one node - label (name) required during install
- GitHub CLI on swarm manager
- GitHub Secrets:
DOCKERHUB_USERNAMEDOCKERHUB_TOKENSWARM_HOSTSWARM_USERSSH_PRIVATE_KEY
- Optional:
- NGINX Proxy Manager running
- Cloudflare credentials (for DNS automation)
- Passwords are visibile during setup for verification. Modify the script to hide passwords using -sp instead of -p if you want to hide the passwords.
Create a new private repo for your WordPress site using this template.
Edit:
docker-compose.yml.github/workflows/docker-build.yml
Change:
- Site/domain name
- DB credentials
- Image name (
yourdockerhub/wp_sitename)
This triggers:
- Docker image build via GitHub Actions
- Image push to Docker Hub
- Deployment to your Docker Swarm
- Elementor
- Rank Math SEO
- Code Snippets
- WP Mail SMTP
- UpdraftPlus
- WPForms Lite
- Cloudflare
- WP Optimize
The /scripts/createPrivateSiteFromTemplate.sh script should be copied and run on your Docker Swarm manager to:
- Clone this template
- Customize values for a new WordPress site
- Create a new private repo
- Push and trigger CI/CD deployment
- GitHub CLI authentication required on swarm manager:
- gh auth login (then choose)
- GitHub.com
- HTPPS
- Paste your token (recommended) or authenticate via browser
- gh auth login (then choose)
Run it with:
- mkdir -p /scripts
- chmod +x /scripts/createPrivateSiteFromTemplate.sh
- ./scripts/createPrivateSiteFromTemplate.sh
To delete a site from the swarm:
run /scripts/deleteSiteFromSwarm.sh
This project is licensed under the MIT License.
- This repo is meant to be a clean base. You can fork it or use it as a GitHub template.
- For each client/site, spin up a new private repo using this template.
- Secrets should be managed securely via GitHub Actions or a vault.
Made with ❤️ by Mark Wood - Prospect Match LLC