version: '3.1'

services:
  xdai_execution:
    container_name: xdai_execution
    image: nethermind/nethermind:latest
    restart: unless-stopped
    stop_grace_period: 1m
    networks:
      - chains
    ports:
      - 30304:30304/tcp # p2p
      - 30304:30304/udp # p2p
    expose:
      - 8545 # rpc
      - 8551 # engine api
    volumes:
      - xdai_execution:/data
      - .jwtsecret:/jwt.hex
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    command: |
      --config=xdai
      --datadir=/data
      --log=INFO
      --Sync.SnapSync=false
      --JsonRpc.Enabled=true
      --JsonRpc.Host=0.0.0.0
      --JsonRpc.Port=8545
      --JsonRpc.EnabledModules=[Web3,Eth,Subscribe,Net,]
      --JsonRpc.JwtSecretFile=/jwt.hex
      --JsonRpc.EngineHost=0.0.0.0
      --JsonRpc.EnginePort=8551
      --Network.DiscoveryPort=30304
      --HealthChecks.Enabled=false
      --Pruning.CacheMb=2048
    labels:
      - "traefik.enable=true"
      - "traefik.http.middlewares.xdai-stripprefix.stripprefix.prefixes=/xdai"
      - "traefik.http.services.xdai.loadbalancer.server.port=8545"
      - "traefik.http.routers.xdai.entrypoints=websecure"
      - "traefik.http.routers.xdai.tls.certresolver=myresolver"
      - "traefik.http.routers.xdai.rule=Host(`$DOMAIN`) && PathPrefix(`/xdai`)"
      - "traefik.http.routers.xdai.middlewares=xdai-stripprefix, ipwhitelist"

  xdai_consensus:
    container_name: xdai_consensus
    image: sigp/lighthouse:latest-modern
    restart: unless-stopped
    networks:
      - chains
    ports:
      - 9001:9001/tcp # p2p
      - 9001:9001/udp # p2p
    expose:
      - 5054 # metrics
      - 4000 # http
    volumes:
      - xdai_consensus:/data
      - .jwtsecret:/jwt.hex
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    command: |
      lighthouse
      beacon_node
      --network=gnosis
      --disable-upnp
      --datadir=/data
      --port=9001
      --http
      --http-address=0.0.0.0
      --http-port=4000
      --target-peers=50
      --execution-endpoint=http://xdai_execution:8551
      --execution-jwt=/jwt.hex
      --debug-level=info
      --validator-monitor-auto
      --subscribe-all-subnets
      --import-all-attestations
      --metrics
      --metrics-port=5054
      --metrics-address=0.0.0.0
      --checkpoint-sync-url=https://checkpoint.gnosischain.com/

volumes:
    xdai_execution:
    xdai_consensus: