Skip to content

Docker Deployment

Koen Teuwen edited this page Jun 4, 2021 · 16 revisions

Makefile

The repository contains a Makefile with many useful operations. Some are highlighted below, but for a full overview, see the Makefile itself.

Development

Clone the repository and copy .env.dist to .env, the contents of the environment file are passed to the Docker container. You should change APP_ENV to development, you can adjust the other environment variables as you wish.

To run the development version you can use docker-compose up -d. If you made changes you can also use make rundev (you can run docker-compose up -d --build instead if you only made code changes). This will rebuild the docker images with the changes you made and deploy these.

After this you should run ./dockerexec ./web orm:schema-tool:create to build the database and you can generate testdata using the following commands:

./dockerexec ./web testdata user
./dockerexec ./web testdata activity
./dockerexec ./web testdata decision
./dockerexec ./web testdata education
./dockerexec ./web testdata page
./dockerexec ./web testdata photo
./dockerexec ./web testdata poll

You can also run a version of the production images locally using make runprod.

Many IDEs are more convenient to work with when dependencies are found because it improves the understanding the IDE has about the code. To copy the composer dependencies from the container run make getvendordir.

Managing dependencies

To update dependencies (composer.lock, package-lock.json) and to renew the stylesheet, you can run make update. There also exist seperate make actions for these.

Managing images

To renew all images, run make all. You can also only renew the production or development images using make prod and make dev respectively. The first time you can one of these commands, Docker may ask for credentials for the GEWIS image server.

Deploying in Portainer

Portainer sadly does not accept the .env file, so you need to use the commented out environment variables in docker-compose.yml. Just copy the main compose file and deploy this in Portainer as a stack.

To renew the image used by Portainer, stop (do not delete or you will delete the volumes as well) the stack. Then go to images and delete the image that you want to renew. When you start the stack again, Portainer will pull the fresh image.

Speeding up builds

While the Dockerfiles are optimized to encourage fast builds in parallel, it can be made slightly faster by enabling Docker BuildKit.