# =============================================================================
# Presence 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:
  presence-service:
    build: .
    container_name: rwa-presence-service
    ports:
      - "3011:3011"
    environment:
      # Application
      - NODE_ENV=production
      - APP_PORT=3011
      - API_PREFIX=api/v1
      # Database (shared PostgreSQL)
      - DATABASE_URL=postgresql://rwa_user:rwa_secure_password@rwa-postgres:5432/rwa_presence?schema=public
      # Redis (shared)
      - REDIS_HOST=rwa-redis
      - REDIS_PORT=6379
      - REDIS_PASSWORD=${REDIS_PASSWORD:-}
      - REDIS_DB=10
      # JWT
      - JWT_SECRET=${JWT_SECRET:-your-super-secret-jwt-key-change-in-production}
      # Kafka (shared)
      - KAFKA_ENABLED=true
      - KAFKA_BROKERS=rwa-kafka:29092
      - KAFKA_CLIENT_ID=presence-service
      - KAFKA_GROUP_ID=presence-service-group
      # Presence
      - PRESENCE_WINDOW_SECONDS=180
      - SNAPSHOT_INTERVAL_SECONDS=60
      # Timezone
      - TZ=Asia/Shanghai
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:3011/api/v1/health"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s
    restart: unless-stopped
    networks:
      - rwa-network

networks:
  rwa-network:
    external: true
