# OMNL Bank — full production stack (128-chain support)
# Usage: docker compose -f docker-compose.omnl-production.yml up -d

services:
  token-aggregation:
    build:
      context: ./services/token-aggregation
      dockerfile: Dockerfile
    ports:
      - "3000:3000"
    env_file:
      - ./config/deployment-omnl.production.env
    environment:
      - NODE_ENV=production
      - PORT=3000
      - OMNL_SUPPORTED_CHAINS_CONFIG=/app/config/omnl-supported-chains.v1.json
    volumes:
      - ./config:/app/config:ro
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "node", "-e", "require('http').get('http://localhost:3000/health',r=>process.exit(r.statusCode===200?0:1))"]
      interval: 30s
      timeout: 5s
      retries: 3

  settlement-middleware:
    build:
      context: ./services/settlement-middleware
      dockerfile: Dockerfile
    ports:
      - "3011:3011"
    env_file:
      - ./config/deployment-omnl.production.env
    environment:
      - NODE_ENV=production
      - SETTLEMENT_MIDDLEWARE_PORT=3011
      - SETTLEMENT_MIDDLEWARE_CONFIG=/app/config/settlement-middleware.production.v1.json
      - OMNL_SUPPORTED_CHAINS_CONFIG=/app/config/omnl-supported-chains.v1.json
      - TOKEN_AGGREGATION_URL=http://token-aggregation:3000
    volumes:
      - ./config:/app/config:ro
      - settlement-data:/app/data
    depends_on:
      token-aggregation:
        condition: service_healthy
    restart: unless-stopped

  dbis-exchange:
    build:
      context: ./services/dbis-exchange
      dockerfile: Dockerfile
    ports:
      - "3012:3012"
    env_file:
      - ./config/deployment-omnl.production.env
    environment:
      - NODE_ENV=production
      - DBIS_EXCHANGE_PORT=3012
      - DBIS_EXCHANGE_CONFIG=/app/config/dbis-exchange.production.v1.json
      - OMNL_SUPPORTED_CHAINS_CONFIG=/app/config/omnl-supported-chains.v1.json
      - OMNL_M2_TOKEN_REGISTRY=/app/config/omnl-m2-token-registry.v1.json
      - TOKEN_AGGREGATION_URL=http://token-aggregation:3000
      - SETTLEMENT_MIDDLEWARE_URL=http://settlement-middleware:3011
    volumes:
      - ./config:/app/config:ro
    depends_on:
      settlement-middleware:
        condition: service_started
    restart: unless-stopped

  frontend:
    build:
      context: ./frontend-dapp
      dockerfile: Dockerfile.production
    ports:
      - "3002:80"
    depends_on:
      - dbis-exchange
      - settlement-middleware
      - token-aggregation
    restart: unless-stopped

  nginx:
    image: nginx:alpine
    ports:
      - "443:443"
      - "80:80"
    volumes:
      - ./deploy/nginx/omnl-bank.conf:/etc/nginx/conf.d/default.conf:ro
      - ./deploy/nginx/certs:/etc/nginx/certs:ro
    depends_on:
      - frontend
      - token-aggregation
      - settlement-middleware
      - dbis-exchange
    restart: unless-stopped

volumes:
  settlement-data:
