version: '3.8'

services:
  # Hyperledger Besu Validator Node 1
  besu-validator-1:
    image: hyperledger/besu:latest
    container_name: besu-validator-1
    ports:
      - "8545:8545"  # JSON-RPC
      - "8546:8546"  # WebSocket
      - "30303:30303"  # P2P
    volumes:
      - besu-validator-1-data:/var/lib/besu
      - ./network-config/genesis.json:/config/genesis.json
      - ./network-config/validator-1:/config/keys
    command:
      - --data-path=/var/lib/besu
      - --genesis-file=/config/genesis.json
      - --rpc-http-enabled=true
      - --rpc-http-host=0.0.0.0
      - --rpc-http-port=8545
      - --rpc-http-api=ETH,NET,WEB3,ADMIN,EEA,PRIV,IBFT
      - --rpc-ws-enabled=true
      - --rpc-ws-host=0.0.0.0
      - --rpc-ws-port=8546
      - --rpc-ws-api=ETH,NET,WEB3,ADMIN,EEA,PRIV,IBFT
      - --host-allowlist=*
      - --p2p-host=0.0.0.0
      - --p2p-port=30303
      - --min-gas-price=0
      - --network-id=2024
      - --bootnodes=enode://validator-1@besu-validator-1:30303
    networks:
      - besu-network
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8545"]
      interval: 10s
      timeout: 5s
      retries: 5

  # Hyperledger Besu Validator Node 2
  besu-validator-2:
    image: hyperledger/besu:latest
    container_name: besu-validator-2
    ports:
      - "8547:8545"
      - "8548:8546"
      - "30304:30303"
    volumes:
      - besu-validator-2-data:/var/lib/besu
      - ./network-config/genesis.json:/config/genesis.json
      - ./network-config/validator-2:/config/keys
    command:
      - --data-path=/var/lib/besu
      - --genesis-file=/config/genesis.json
      - --rpc-http-enabled=true
      - --rpc-http-host=0.0.0.0
      - --rpc-http-port=8545
      - --rpc-http-api=ETH,NET,WEB3,ADMIN,EEA,PRIV,IBFT
      - --rpc-ws-enabled=true
      - --rpc-ws-host=0.0.0.0
      - --rpc-ws-port=8546
      - --rpc-ws-api=ETH,NET,WEB3,ADMIN,EEA,PRIV,IBFT
      - --host-allowlist=*
      - --p2p-host=0.0.0.0
      - --p2p-port=30303
      - --min-gas-price=0
      - --network-id=2024
      - --bootnodes=enode://validator-1@besu-validator-1:30303
    networks:
      - besu-network
    depends_on:
      - besu-validator-1

  # Hyperledger Besu Validator Node 3
  besu-validator-3:
    image: hyperledger/besu:latest
    container_name: besu-validator-3
    ports:
      - "8549:8545"
      - "8550:8546"
      - "30305:30303"
    volumes:
      - besu-validator-3-data:/var/lib/besu
      - ./network-config/genesis.json:/config/genesis.json
      - ./network-config/validator-3:/config/keys
    command:
      - --data-path=/var/lib/besu
      - --genesis-file=/config/genesis.json
      - --rpc-http-enabled=true
      - --rpc-http-host=0.0.0.0
      - --rpc-http-port=8545
      - --rpc-http-api=ETH,NET,WEB3,ADMIN,EEA,PRIV,IBFT
      - --rpc-ws-enabled=true
      - --rpc-ws-host=0.0.0.0
      - --rpc-ws-port=8546
      - --rpc-ws-api=ETH,NET,WEB3,ADMIN,EEA,PRIV,IBFT
      - --host-allowlist=*
      - --p2p-host=0.0.0.0
      - --p2p-port=30303
      - --min-gas-price=0
      - --network-id=2024
      - --bootnodes=enode://validator-1@besu-validator-1:30303
    networks:
      - besu-network
    depends_on:
      - besu-validator-1

networks:
  besu-network:
    driver: bridge

volumes:
  besu-validator-1-data:
  besu-validator-2-data:
  besu-validator-3-data:

