# =============================================================================
# Identity 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:
  identity-service:
    build: .
    container_name: rwa-identity-service
    ports:
      - "3000:3000"
    environment:
      - NODE_ENV=production
      - APP_PORT=3000
      # Database (shared PostgreSQL)
      - DATABASE_URL=postgresql://rwa_user:rwa_secure_password@rwa-postgres:5432/rwa_identity?schema=public
      # JWT
      - JWT_SECRET=${JWT_SECRET:-your-super-secret-jwt-key-change-in-production}
      - JWT_ACCESS_EXPIRES_IN=2h
      - JWT_REFRESH_EXPIRES_IN=30d
      # Redis (shared)
      - REDIS_HOST=rwa-redis
      - REDIS_PORT=6379
      - REDIS_PASSWORD=${REDIS_PASSWORD:-}
      - REDIS_DB=0
      # Kafka (shared)
      - KAFKA_BROKERS=rwa-kafka:29092
      - KAFKA_CLIENT_ID=identity-service
      - KAFKA_GROUP_ID=identity-service-group
      # Wallet Encryption
      - WALLET_ENCRYPTION_SALT=${WALLET_ENCRYPTION_SALT:-rwa-wallet-salt-change-in-production}
      # MPC Service
      - MPC_SERVICE_URL=http://rwa-mpc-service:3006
      - MPC_MODE=remote
      - MPC_USE_EVENT_DRIVEN=true
      # Blockchain Service
      - BLOCKCHAIN_SERVICE_URL=http://rwa-blockchain-service:3012
      # Backup Service
      - BACKUP_SERVICE_URL=http://rwa-backup-service:3002
      - BACKUP_SERVICE_ENABLED=true
      - SERVICE_JWT_SECRET=${SERVICE_JWT_SECRET:-your-service-jwt-secret-change-in-production}
      # Blockchain RPC
      - KAVA_RPC_URL=https://evm.kava.io
      - BSC_RPC_URL=https://bsc-dataseed.binance.org
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:3000/api/v1/health"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s
    restart: unless-stopped
    networks:
      - rwa-network

networks:
  rwa-network:
    external: true
