# =============================================================================
# Leaderboard Service - Docker Compose (Development/Standalone)
# =============================================================================
# For production, use the root docker-compose.yml in ../
#
# For standalone development:
#   1. First start shared infrastructure: cd .. && ./deploy.sh up postgres redis kafka
#   2. Then: docker compose up -d --build
# =============================================================================

services:
  leaderboard-service:
    build:
      context: .
      dockerfile: Dockerfile
      target: production
    container_name: rwa-leaderboard-service
    ports:
      - "3007:3007"
    environment:
      # Application
      NODE_ENV: production
      APP_PORT: 3007
      # Database (shared PostgreSQL)
      DATABASE_URL: postgresql://rwa_user:rwa_secure_password@rwa-postgres:5432/rwa_leaderboard?schema=public
      # Redis (shared)
      REDIS_HOST: rwa-redis
      REDIS_PORT: 6379
      REDIS_PASSWORD: ${REDIS_PASSWORD:-}
      REDIS_DB: 6
      # Kafka (shared)
      KAFKA_BROKERS: rwa-kafka:29092
      KAFKA_CLIENT_ID: leaderboard-service
      KAFKA_GROUP_ID: leaderboard-service-group
      # JWT
      JWT_SECRET: ${JWT_SECRET:-your-jwt-secret-for-docker}
      JWT_EXPIRES_IN: 7d
    command: >
      sh -c "npx prisma migrate deploy && node dist/main"
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:3007/api/v1/health"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s
    restart: unless-stopped
    networks:
      - rwa-network

networks:
  rwa-network:
    external: true
