services:
  server:
    build:
      context: .
      target: production
    ports:
      - "8080:8080"
    env_file:
      - .env
    secrets:
      - firebase-service-account
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "wget", "-qO-", "http://localhost:8080/health"]
      interval: 30s
      timeout: 5s
      retries: 3

  # Local dev only — hot-reload without rebuilding the image
  server-dev:
    build:
      context: .
      target: builder
    command: npm run dev
    ports:
      - "8080:8080"
    env_file:
      - .env
    secrets:
      - firebase-service-account
    volumes:
      - ./src:/app/src:ro
    profiles:
      - dev

secrets:
  firebase-service-account:
    file: ./firebase-service-account.json
