# =============================================================================
# Blockchain 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:
  blockchain-service:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: rwa-blockchain-service
    ports:
      - "3012:3012"
    environment:
      # Application
      NODE_ENV: production
      APP_PORT: 3012
      API_PREFIX: api/v1
      # Database (shared PostgreSQL)
      DATABASE_URL: postgresql://rwa_user:rwa_secure_password@rwa-postgres:5432/rwa_mining_blockchain?schema=public
      # Redis (shared)
      REDIS_HOST: rwa-redis
      REDIS_PORT: 6379
      REDIS_DB: 8
      # Kafka (shared)
      KAFKA_BROKERS: rwa-kafka:29092
      KAFKA_CLIENT_ID: mining-blockchain-service
      KAFKA_GROUP_ID: mining-blockchain-service-group
      # Blockchain RPC
      KAVA_RPC_URL: https://evm.kava.io
      BSC_RPC_URL: https://bsc-dataseed.binance.org
      # MPC Hot Wallet (用于提现转账)
      MPC_SERVICE_URL: http://rwa-mpc-service:3013
      HOT_WALLET_USERNAME: ${HOT_WALLET_USERNAME:-}
      HOT_WALLET_ADDRESS: ${HOT_WALLET_ADDRESS:-}
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:3012/api/v1/health"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s
    restart: unless-stopped
    networks:
      - rwa-network

networks:
  rwa-network:
    external: true
