version: "3.9"

services:
  db:
    image: postgres:16-alpine
    restart: unless-stopped
    environment:
      POSTGRES_USER: catan
      POSTGRES_PASSWORD: catan
      POSTGRES_DB: catan
    volumes:
      - catan-db:/var/lib/postgresql/data

  api:
    build:
      context: .
      dockerfile: docker/api.Dockerfile
    restart: unless-stopped
    env_file: .env
    depends_on:
      - db
      - game
      - ai
      - analytics
    networks:
      - default
      - caddy-network

  game:
    build:
      context: .
      dockerfile: docker/game.Dockerfile
    restart: unless-stopped
    env_file: .env
    depends_on:
      - db
    networks:
      - default
    volumes:
      - ./models:/models

  ai:
    build:
      context: .
      dockerfile: docker/ai.Dockerfile
    restart: unless-stopped
    env_file: .env
    depends_on:
      - db
    networks:
      - default
    volumes:
      - ./models:/models

  analytics:
    build:
      context: .
      dockerfile: docker/analytics.Dockerfile
    restart: unless-stopped
    env_file: .env
    depends_on:
      - db
    networks:
      - default

  web:
    build:
      context: .
      dockerfile: docker/web.Dockerfile
    restart: unless-stopped
    depends_on:
      - api
    networks:
      - default
      - caddy-network

volumes:
  catan-db:

networks:
  caddy-network:
    external: true
