This repository provides a Docker-based workspace that includes Traefik, Nginx/Apache, MySQL, automatic SSL certificates and MailHog.
To ensure everything works flawlessly, follow these steps:
- For Windows users: Replace all occurrences of
.test
with.localhost
in the instructions and files. - For macOS users: Keep
.test
but also create persistent loopback interface and install and configure dnsmasq
In traefik
directory, run:
docker network create proxy
docker-compose up -d
- In
mysql8
andmysql57
directories, run:
docker-compose up -d
- You can access MySQL via MySQL Workbench, TablePlus, HeidiSQL, etc., using the following:
mysql8
: Hostname127.0.0.1
, Port3306
, Username:root
, Password:root
mysql57
: Hostname127.0.0.1
, Port3307
, Username:root
, Password:root
- In
mailhog
directory, run:
docker-compose up -d
- Visit
mailhog.test
in your browser to browse mails
- Clone a template from the
template
directory into theprojects
directory. - Rename the directory, e.g.,
newproject1
. - Edit the
.env
file to name your project, preferably using the same name as the directory. - Optionally: setup project specific mysql container (commented out in docker-compose file) or switch nginx with apache
- Place your application files into the
src
directory. - Copy
minica.pem
fromtraefik/certificates
toprojects/newproject1/.docker/php/certs
- Run
docker-compose up -d
This is one time step - you don't have to do it every time. MiniCA will create certificates automatically for each new project.
- Copy
traefik/certificates/minica.pem
to your local machine - Run command
openssl x509 -outform der -in minica.pem -out minica.crt
- Right click
minica.crt
- Install certificate -> Place certificate in the following store -> Trusted Root Certification Authorities
- Restart browser
For the mysql57
container, data is stored in the mysql57/data
directory.
For the mysql8
container, data is stored in the mysql8/data
directory.
To connect to the MySQL container in your project, use mysql57
or mysql8
as the hostname. For example, in a WordPress configuration:
define('DB_NAME', 'newproject1');
define('DB_USER', 'root');
define('DB_PASSWORD', 'root');
define('DB_HOST', 'mysql8'); // Use the container name for MySQL 8.0
You can also set up each project with its own MySQL instance if specific configurations are needed. Ensure to use a unique port number (set up inside the .env
file). If using a predefined MySQL configuration, your project’s MySQL instance container should be named APP_NAME-mysql
- where APP_NAME is taken from the .env
file.
For the project's MySQL instance, data is stored inside the [project catalog]/.docker/mysql/data
directory.
Replace APP_NAME
with your app name:
- Enter bash inside container
docker exec -it APP_NAME-php bash
- Execute command e.g.
composer install
- Type
exit
to leave
Include:
- Composer
- WP-CLI
- Wordfence-CLI
- you can run a vulnerability scan with the following command:
wordfence vuln-scan .
- Makefile with a few usefull scripts
make admin
- will create "admin" account with password "admin". To see list of all commands check Makefile