version: '3.8'

services:
  besu-validator:
    image: hyperledger/besu:23.10.0
    container_name: besu-validator
    restart: unless-stopped
    volumes:
      - ./data:/data
      - ./config:/config
      - ./keys:/keys:ro
      - ./logs:/logs
    ports:
      - "30303:30303"      # P2P TCP
      - "30303:30303/udp"  # P2P UDP
      - "9545:9545"        # Metrics
    command:
      - /opt/besu/bin/besu
      - --config-file=/config/besu-config.toml
    environment:
      - BESU_OPTS=-Xmx4g -Xms4g
    networks:
      - besu-network
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "3"
    healthcheck:
      test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:9545/metrics"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 120s
    deploy:
      resources:
        limits:
          cpus: '4'
          memory: 8G
        reservations:
          cpus: '2'
          memory: 4G

networks:
  besu-network:
    driver: bridge

