version: "3.9"

services:
  db:
    image: postgres:16-alpine
    environment:
      POSTGRES_USER: catan
      POSTGRES_PASSWORD: catan
      POSTGRES_DB: catan
    ports:
      - "5432:5432"
    volumes:
      - catan-db:/var/lib/postgresql/data

  api:
    build:
      context: .
      dockerfile: docker/api.Dockerfile
    env_file: .env
    ports:
      - "8000:8000"
    depends_on:
      - db
      - game
      - ai
      - analytics

  game:
    build:
      context: .
      dockerfile: docker/game.Dockerfile
    env_file: .env
    ports:
      - "8001:8001"
    depends_on:
      - db
    volumes:
      - ./models:/models

  ai:
    build:
      context: .
      dockerfile: docker/ai.Dockerfile
    env_file: .env
    ports:
      - "8002:8002"
    depends_on:
      - db
    volumes:
      - ./models:/models

  analytics:
    build:
      context: .
      dockerfile: docker/analytics.Dockerfile
    env_file: .env
    ports:
      - "8003:8003"
    depends_on:
      - db

  web:
    build:
      context: .
      dockerfile: docker/web.Dockerfile
    ports:
      - "8080:80"
    depends_on:
      - api

volumes:
  catan-db:
