services:
  postgres:
    image: postgres:16-alpine
    environment:
      POSTGRES_USER: matchmaking
      POSTGRES_PASSWORD: matchmaking
      POSTGRES_DB: matchmaking
    ports:
      - "5433:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U matchmaking"]
      interval: 5s
      timeout: 5s
      retries: 5

  api:
    build: .
    env_file: .env
    ports:
      - "8100:8000"
    depends_on:
      postgres:
        condition: service_healthy
    extra_hosts:
      # Lets the container reach a Godot dev server running on the host
      # (Linux Docker Engine doesn't resolve host.docker.internal by default).
      - "host.docker.internal:host-gateway"
    volumes:
      - ./app:/app/app
    command: ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]

volumes:
  postgres_data:
