A simplified Docker Compose workflow that sets up a network of containers for local development. You can view the full article that inspired this repo here.
To get started, make sure you have Docker installed on your system, and then clone this repository.
Next, navigate in your terminal to the directory you cloned this, and spin up the containers for the web server by running docker-compose up --build -d site
.
After that completes, follow the steps from the src/README.md for setting up the authors project, or create your own README instructions specific to your project build.
Bringing up the Docker Compose network with site
instead of just using up
, ensures that only our site's containers are brought up at the start, instead of all of the command containers as well. The following are built for our web server, with their exposed ports detailed:
- webserver -
:8080
- database -
:5432
- api -
:9000
By default, whenever you bring down the Docker network, your data will be removed after the containers are destroyed. If you would like to have persistent data that remains after bringing containers down and back up, do the following:
- Create a
dbdata
folder in theinfrastructure
root. - Under the database service in your
docker-compose.yml
file, add the following lines:
volumes:
- ./dbdata:/path/to/database/data
Unlike our MySQL containers, our Postgres containers
do not come with a DBMS container. We recommend setting
up DataGrip to connect to the database, you can access the
postgres container via docker exec -ti webserver sh
once inside the container you can access the data base as you would in a normal environment psql@databaseName
.
While it is possible to manage the database in this manner, it can be tedious and difficult to manage. PGAdmin is a free tool, however, we prefer DataGrip. If you wish to add a PGAdmin container you can add a service to the docker-compose from the official docker hub image.
exec into php container: docker exec -ti php sh
install dependencies: composer install
run node install: docker run --rm node install
exec into php container: docker exec -ti php sh
change ownership:
chown -R www-data: storage
chown -R www-data: bootstrap/cache