Easily set up a local development environment for your existing WordPress site using Docker. This solution is ideal for developing and testing in an environment that mirrors your live site.
- Docker and Docker Compose installed.
-
WordPress Container:
- Volumes:
site/wp-content
: Place your productionwp-content
folder here. It includes themes, plugins, uploads, etc. 🎨
- Volumes:
-
Database (DB) Container:
- Volumes:
mysqldumps/backup.sql.gz
: Put your production database snapshot here. It's imported automatically on first run. 🔄init/migrate.sh
: URL migration script, runs automatically. 🌐
- Volumes:
- Clone/Download: Get the project files. 👨💻
- Database Prep: Create a dump from the live database and save it as
mysqldumps/backup.sql.gz
. 🗃️ - Content Prep: Copy
wp-content
from your site tosite/wp-content
. 📂 - Configuration: Set variables in
.env
. 📝 - Run: In the project root, execute:
docker-compose up -d && docker exec -ti wordpress '/prep.sh'
Access your site at http://localhost
and the admin panel at http://localhost/wp-admin
. 🌍
Enjoy a seamless and efficient development process for your WordPress site! 🎉