currently, I am working a lot with WordPress and for every project, my company wants different environments. So first of all we have our development environment which is running on our own server. Then there is the staging environment on the client's server and also the live(production) environment. Also, there is the local environment in which every participant developer is working on whatever features.
Since this is always a time-consuming hustle, I would love to use Docker to make things more straight forward. So I set up my local environment with a docker-compose and create a MySql,WordPress and phpMyAdmin container.
With a shell script, I add a WordPress-theme and the Plugins from our private Gitlab repository as a submodule followed by the docker-compose up -d.
After all the containers are up and running I wait for a connection to the MySql-Database and then feed it with my backup.sql file.
That's all working fine so far...
version: '3.8'
volumes:
wp-content: {}
mysql-backup: {}
networks:
wp-back:
services:
db:
build:
context: .
dockerfile: Dockerfile-mysql
container_name: mysql-cont
volumes: ['mysql-backup:/root']
environment:
MYSQL_ROOT_PASSWORD: rootPassword
MYSQL_DATABASE: wordpress
MYSQL_USER: wp-user
MYSQL_PASSWORD: wp-pass
ports:
- 8889:3306
networks:
- wp-back
restart: always
phpmyadmin:
depends_on:
- db
image: phpmyadmin/phpmyadmin
container_name: pma-cont
environment:
PMA_HOST: db
MYSQL_USER: wp-user
MYSQL_PASSWORD: wp-pass
MYSQL_ROOT_PASSWORD: rootPassword
ports:
- 3001:80
restart: always
networks:
- wp-back
wordpress:
depends_on:
- db
container_name: wp-cont
build:
context: .
dockerfile: Dockerfile-wordpress
ports:
- 8000:80
- 443:443
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: wp-user
WORDPRESS_DB_PASSWORD: wp-pass
volumes: ['./wp-content:/var/www/html/wp-content']
networks:
- wp-back
restart: always
But regarding my needs with the 3 different environments, I am struggling with a setup where I can easily take everything that I created local and put it on the other 2 servers (dev & staging/live) Because I always have the theme and the backup.sql in my docker volume, I somehow need to share that with other developers and the servers. I mean for the WordPress theme I could just work with pulling it from the project's private GitLab repository. But what to do with the .sql file? Where is the best place to put it? Should I put Dockerfile, wp-content and backup.sql into one single repository for the project? It's getting pretty heavy then
Furthermore, let's say after a year I want to be able to easily set up the project in my local environment with the MySQL-database and WordPress uploads from the live environment. But I don't find a solution.
I appreciate any kind of brainstorming, ideas, help or links.
Cheers