# 1. Copy config.example.json to docker/config.json and edit it
#    (set Database.Host to "db", adjust password to match below)
# 2. Place quest/scenario files in docker/bin/
# 3. docker compose up
services:
  db:
    image: postgres:18-alpine
    environment:
      # Change this password and match it in docker/config.json
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=password
      - POSTGRES_DB=erupe
    ports:
      - "5432:5432"
    volumes:
      - ./db-data/:/var/lib/postgresql/
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres"]
      interval: 5s
      timeout: 5s
      start_period: 5s
      retries: 5
  pgadmin:
    image: dpage/pgadmin4
    restart: always
    environment:
      PGADMIN_DEFAULT_EMAIL: user@pgadmin.com
      PGADMIN_DEFAULT_PASSWORD: password
    ports:
      - "5050:80"
    depends_on:
      db:
        condition: service_healthy
  server:
    depends_on:
      db:
        condition: service_healthy
    image: ghcr.io/mezeporta/erupe:main
    # To build locally instead of using the prebuilt image, comment out
    # the 'image' line above and uncomment the 'build' section below:
    # build:
    #   context: ../
    volumes:
      - ./config.json:/app/config.json
      - ./bin:/app/bin
      - ./savedata:/app/savedata
    ports:
      # (Make sure these match config.json)
      - "53312:53312" #Sign V1
      - "8080:8080"   #Sign V2
      - "53310:53310" #Entrance
      # Channels
      - "54001:54001"
      - "54002:54002"
      - "54003:54003"
      - "54004:54004"
      - "54005:54005"
      - "54006:54006"
      - "54007:54007"
      - "54008:54008"
    healthcheck:
      test: ["CMD", "wget", "-qO-", "http://localhost:8080/health"]
      interval: 10s
      timeout: 3s
      start_period: 15s
      retries: 3
