# =============================================================================
# Backup 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:
  backup-service:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: rwa-backup-service
    ports:
      - "3002:3002"
    environment:
      # Application
      - NODE_ENV=production
      - APP_PORT=3002
      - APP_ENV=production
      # Database (shared PostgreSQL)
      - DATABASE_URL=postgresql://rwa_user:rwa_secure_password@rwa-postgres:5432/rwa_backup?schema=public
      # Service Authentication
      - SERVICE_JWT_SECRET=${SERVICE_JWT_SECRET:-your-service-jwt-secret}
      - ALLOWED_SERVICES=identity-service,recovery-service,mpc-service
      # Backup Encryption
      - BACKUP_ENCRYPTION_KEY=${BACKUP_ENCRYPTION_KEY:-0123456789abcdef0123456789abcdef}
      - BACKUP_ENCRYPTION_KEY_ID=${BACKUP_ENCRYPTION_KEY_ID:-key-v1}
      # Rate Limits
      - MAX_RETRIEVE_PER_DAY=3
      - MAX_STORE_PER_MINUTE=10
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:3002/health"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s
    restart: unless-stopped
    networks:
      - rwa-network

networks:
  rwa-network:
    external: true
