The web development team The Wilds has decided to set up our local development environments through the orchestration of Docker containers. This has allowed us to develop on different systems while maintaining some consistency in how the development environments are configured.
-
A working install of Docker Desktop. This will work under Windows, Mac OS, or Linux.
-
Docker Compose. This should be installed with Docker, but we're putting it here for completeness.
-
(Recommended) Docker Desktop using WSL 2 backend on Windows. This is recommended for performance.
docker-comose up
would be run from inside WSL 2 and mapping folders from WSL 2 instead of from Windows.
-
Download the
docker-compose.yml
anddocker-compose.override.yml
from this repo. -
Modify the appropriate environment variables inside your local copy of the
docker-compose.override.yml
file. See the appropriate container definitions for details on specific environment variables. -
Open incoming TCP port
9000
on your development machine (presumably the computer hosting Docker) for accepting Xdebug events from the wildscamp/php container. You may be able to narrow down the scope of this rule by identifying which IP subnet the containers are running in. -
Start the environment. While inside the folder containing the
docker-compose*.yml
files run the following command:docker-compose up
If you are using WSL 2, it is highly recommended to run this command from your project folder inside of the WSL 2 shell. The folder mapping is much faster from WSL 2 than from Windows.
The first time it will take a while for Docker to download and then start the containers. After this, starting up the environment should be much faster. Stopping all the containers can be accomplished by hitting the
Ctrl + C
key sequence in the terminal that is running thedocker-compose up
command.
Once the containers are up and running, they can be accessed through a few different ways.
There are two ways to access the MySQL databases.
-
If you have a client MySQL browser (like PhpStorm's Database Browser), you can connect directly to the database using the
localhost
or127.0.0.1
and port3306
. -
The
docker-compose.yml
file is configured to spin up a phpMyAdmin instance with access to the MySQL server. You can access it athttp://localhost:8080/
.Account Info
Username Password Database Name root pw local_db
Accessing the web application can be done simply by navigating to
http://localhost/
. If you've defined a DNS name that points to
127.0.0.1
, you could use that as well instead of the IP directly.
This also supports HTTPS if you have defined some certificates. The
docker-compose.override.yml
file gives an example of using a LetsEncrypt cert.