Skip to content

Docker Deployment

Tom Udding edited this page Oct 20, 2024 · 20 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 make rundev. This will rebuild the docker images with the changes you made and deploy these.

After this, you should run make migration-migrate to build the database.

You can now access the test version of the website at http://localhost:80. You can also access PhpMyAdmin at http://localhost:8080 where you can modify the database schema and alter data.

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

Images are available on the GEWIS package repository.

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.

Replenishing shared volumes with new files

When you deploy a new version of the container, the shared volumes are not updated automatically. If any changes are made to the default contents of these, you can run make replenish. On Portainer, you can run sh ./replenish.sh inside the container to pull changes from GEWIS/gewisweb/master.

Speeding up builds

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