Deployment - uol-esis/TH1 GitHub Wiki

Warning

This guide is currently outdated and will be updated soon.

The deployment is done using Docker. The easiest way is to use the latest docker image provided in the container registry here on github. The following docker-compose.yml file can be used to deploy the whole stack with the TH1 backend, a dedicated database and metabase for visualization.

name: TH1-stack

services:

  th1:
    image: ghcr.io/uol-esis/th1:latest
    restart: unless-stopped
    env_file:
      - th1.env
    ports:
      - "8080:8080"
    depends_on:
      th1-db:
        condition: service_healthy
    networks:
      - th1-network

  th1-db:
    image: postgres:17.4-alpine
    container_name: th1-db
    restart: unless-stopped
    env_file:
      - th1-db.env
    volumes:
      - ./th1-data:/var/lib/postgresql/data
    networks:
      - th1-network
    healthcheck:
      test: [ "CMD-SHELL", "pg_isready" ]
      interval: 5s
      timeout: 5s
      retries: 10

  metabase-db:
    image: postgres:17.4-alpine
    container_name: metabase-db
    restart: unless-stopped
    env_file:
      - metabase-db.env
    volumes:
      - ./metabase-data:/var/lib/postgresql/data
    networks:
      - metabase-network
    healthcheck:
      test: [ "CMD-SHELL", "pg_isready" ]
      interval: 5s
      timeout: 5s
      retries: 10

  metabase:
    image: metabase/metabase
    container_name: metabase
    restart: unless-stopped
    env_file:
      - metabase.env
    ports:
      - "3000:3000"
    depends_on:
      metabase-db:
        condition: service_healthy
      th1-db:
        condition: service_healthy
    networks:
      - metabase-network 
      - th1-network

networks:
  metabase-network:
    name: metabase-network
  th1-network:
    name: th1-network

Furthermore, the following env variables should be provided:

th1.env:

SPRING_DATASOURCE_USERNAME=data
SPRING_DATASOURCE_PASSWORD=data
SPRING_DATASOURCE_URL=jdbc:postgresql://th1-db:5432/data
MB_API_KEY=<key>
MB_API_GENERAL_KEY=<key>
MB_API_BASEPATH=http://metabase:3000/api
SERVER_FORWARD-HEADERS-STRATEGY=framework

th1-db.env:

POSTGRES_DB=data
POSTGRES_USER=data
POSTGRES_PASSWORD=data
PGUSER=data

metabase.env:

MB_DB_TYPE=postgres
MB_DB_DBNAME=bi
MB_DB_PORT=5432
MB_DB_USER=bi
MB_DB_PASS=bi
MB_DB_HOST=metabase-db
MB_API_KEY=<key>

metabase-db.env:

POSTGRES_DB=bi
POSTGRES_USER=bi
POSTGRES_PASSWORD=bi
PGUSER=bi

Note

For correct communication of TH1 with Metabase an API KEY needs to be generated as an admin in Metabase. This variable needs to be provided in th1.env as MB_API_GENERAL_KEY. Furthermore, the env variable MB_API_KEY needs to be set in both th1.env and metabase.env. MB_API_KEY needs to be equal in both env files but the value itself can be freely chosen.

Run it

When everything is in place the whole stack can be started using the following command:

docker compose up -d
⚠️ **GitHub.com Fallback** ⚠️