Docker - uol-esis/TH1 GitHub Wiki

Building on top of the quickstart tips in the README.md this page will describe how to set up the TH1 Application using docker.

Prerequisites:

  • cloned Repository of TH1
  • Docker and Docker Compose (tested with v27.5.1 and v2.32.4 respectively)
  • free ports 8080, 5432 and 8085

Setup

The docker-compose.yaml file inside the docker directory comes with all necessary settings to directly spin up the the whole stack for local development.

[!NOTE] It is strongly recommended to not use the default values!

Running the application

To run the whole stack you can use the following command in the root of the repository:

docker compose -f docker/docker-compose.yaml up -d && docker compose -f docker/docker-compose.yaml logs -f

On the very first run of this command, the application will be build. Further runs will use the cached image. The application as well as the database and keycloak will run in the background so performing CTRL+C will not stop the containers from running but only stop the logs from showing. To stop the stack run the following command again in the root of the repository:

docker compose -f docker/docker-compose.yaml down

Rebuilding the app image

As stated above, the build will be performed once and then be cached. If you are working on the code and need to rebuild the image based on your changes, you need to pass the --build flag to the starting command:

docker compose -f docker/docker-compose.yaml up -d --build && docker compose -f docker/docker-compose.yaml logs -f

Running selected services

In case you only need selected services, for example the database for local testing, you can run the following command:

docker compose -f docker/docker-compose.yaml up -d db && docker compose -f docker/docker-compose.yaml logs -f

Note the db after the -d flag selecting only the db service.

Tips and tricks

Here are some tips and tricks you can keep in mind when developing or deploying the application.

  • The default db config is to expose the port to localhost. This is useful during testing. However, when deployed, you might want to remove the port publishing from the db config in the docker-compose.yaml file so only services in the same docker network can access the database. This will increase the security.