version: '3.8'

services:
  postgres:
    image: postgres:15-alpine
    environment:
      POSTGRES_DB: ccip_relayer
      POSTGRES_USER: ccip
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-changeme}
    volumes:
      - postgres_data:/var/lib/postgresql/data
    ports:
      - "5432:5432"
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ccip"]
      interval: 10s
      timeout: 5s
      retries: 5

  relayer:
    build:
      context: ..
      dockerfile: docker/Dockerfile
    environment:
      DATABASE_URL: postgresql://ccip:${POSTGRES_PASSWORD:-changeme}@postgres:5432/ccip_relayer
      CHAIN138_RPC_WS: ${CHAIN138_RPC_WS}
      CHAIN138_RPC_HTTP: ${CHAIN138_RPC_HTTP}
      ETHEREUM_RPC: ${ETHEREUM_MAINNET_RPC}
      CCIP_REPORTER_CHAIN138_ADDRESS: ${CCIP_REPORTER_CHAIN138_ADDRESS}
      CCIP_LOGGER_ETH_ADDRESS: ${CCIP_LOGGER_ETH_ADDRESS}
      RELAYER_PRIVATE_KEY: ${RELAYER_PRIVATE_KEY}
      BATCH_SIGNER_PRIVATE_KEY: ${BATCH_SIGNER_PRIVATE_KEY}
      BATCH_SIZE: ${BATCH_SIZE:-10}
      BATCH_INTERVAL_MS: ${BATCH_INTERVAL_MS:-60000}
      CONFIRMATIONS_REQUIRED: ${CONFIRMATIONS_REQUIRED:-12}
      LOG_LEVEL: ${LOG_LEVEL:-info}
    depends_on:
      postgres:
        condition: service_healthy
    restart: unless-stopped
    volumes:
      - ./logs:/app/logs

  prometheus:
    image: prom/prometheus:latest
    volumes:
      - ./prometheus.yml:/etc/prometheus/prometheus.yml
      - prometheus_data:/prometheus
    command:
      - '--config.file=/etc/prometheus/prometheus.yml'
      - '--storage.tsdb.path=/prometheus'
    ports:
      - "9090:9090"

volumes:
  postgres_data:
  prometheus_data:
