services:
  db:
    build:
      context: .
      dockerfile: postgres/Dockerfile
    image: ghcr.io/tig-foundation/tig-monorepo/benchmarker/postgres:${VERSION}
    container_name: db
    restart: unless-stopped
    environment:
      - POSTGRES_USER=${POSTGRES_USER}
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
      - POSTGRES_DB=${POSTGRES_DB}
    volumes:
      - ./db_data:/var/lib/postgresql/data
    networks:
      - tig-benchmarker
    ports:
      - ${DB_PORT}:5432
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER}"]
      interval: 5s
      timeout: 5s
      retries: 5

  master:
    build:
      context: .
      dockerfile: master/Dockerfile
    image: ghcr.io/tig-foundation/tig-monorepo/benchmarker/master:${VERSION}
    environment:
      - POSTGRES_USER=${POSTGRES_USER}
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
      - POSTGRES_DB=${POSTGRES_DB}
      - POSTGRES_HOST=db
      - VERBOSE=${VERBOSE}
    networks:
      - tig-benchmarker
    ports:
      - ${MASTER_PORT}:5115
    expose:
      - 3336
    depends_on:
      db:
        condition: service_healthy

  ui:
    build:
      context: .
      dockerfile: ui/Dockerfile
    image: ghcr.io/tig-foundation/tig-monorepo/benchmarker/ui:${VERSION}
    restart: unless-stopped
    networks:
      - tig-benchmarker
    expose:
      - 80
    depends_on:
      - master

  nginx:
    build:
      context: .
      dockerfile: nginx/Dockerfile
    image: ghcr.io/tig-foundation/tig-monorepo/benchmarker/nginx:${VERSION}
    ports:
      - "${UI_PORT}:80"
    networks:
      - tig-benchmarker
    depends_on:
      - ui
      - master

networks:
  tig-benchmarker:

volumes:
  pgadmin-data:
