version: '3.8'

services:
  keeper:
    build:
      context: ..
      dockerfile: docker/Dockerfile.keeper
    container_name: price-feed-keeper
    restart: unless-stopped
    environment:
      - RPC_URL_138=${RPC_URL_138:-https://rpc.d-bis.org}
      - KEEPER_PRIVATE_KEY=${KEEPER_PRIVATE_KEY}
      - PRICE_FEED_KEEPER_ADDRESS=${PRICE_FEED_KEEPER_ADDRESS}
      - UPDATE_INTERVAL=${UPDATE_INTERVAL:-30}
      - NODE_ENV=production
    volumes:
      - ./logs:/app/logs
      - ./config:/app/config
    networks:
      - keeper-network
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "3"
    healthcheck:
      test: ["CMD", "node", "-e", "require('http').get('http://localhost:3000/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s

  monitor:
    build:
      context: ..
      dockerfile: docker/Dockerfile.monitor
    container_name: keeper-monitor
    restart: unless-stopped
    environment:
      - RPC_URL_138=${RPC_URL_138:-https://rpc.d-bis.org}
      - PRICE_FEED_KEEPER_ADDRESS=${PRICE_FEED_KEEPER_ADDRESS}
      - ALERT_WEBHOOK=${ALERT_WEBHOOK}
      - CHECK_INTERVAL=${CHECK_INTERVAL:-60}
    volumes:
      - ./logs:/app/logs
    networks:
      - keeper-network
    depends_on:
      - keeper

networks:
  keeper-network:
    driver: bridge

