version: '3.1'

services:
  nethermind-goerli:
    image: nethermind/nethermind:1.17.3
    restart: always
    stop_grace_period: 1m
    command: |
      --JsonRpc.Enabled=true
      --JsonRpc.JwtSecretFile=/jwt.hex
      --Metrics.Enabled=true
    ports:
      - '29911:29911/tcp' # p2p
      - '29911:29911/udp' # p2p
    networks:
      - chains
    volumes:
      - nethermind_goerli_db:/nethermind/nethermind_db
      - nethermind_goerli_keystore:/nethermind/keystore
      - nethermind_goerli_logs:/nethermind/logs
      - .jwtsecret:/jwt.hex
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    environment:
      - NETHERMIND_CONFIG=goerli
      - NETHERMIND_JSONRPCCONFIG_ENGINEENABLEDMODULES=[Eth,AccountAbstraction,Subscribe,TxPool,Web3,Personal,Proof,Net,Parity,Health]
      - NETHERMIND_JSONRPCCONFIG_ENGINEHOST=0.0.0.0
      - NETHERMIND_JSONRPCCONFIG_ENGINEPORT=8551
      - NETHERMIND_JSONRPCCONFIG_HOST=0.0.0.0
      - NETHERMIND_METRICSCONFIG_EXPOSEPORT=9091
      - NETHERMIND_NETWORKCONFIG_P2PPORT=29911
      - NETHERMIND_NETWORKCONFIG_DISCOVERYPORT=29911
      - NETHERMIND_NETWORKCONFIG_MAXACTIVEPEERSOA=150
      - NETHERMIND_SYNCCONFIG_FASTSYNC=true
      - NETHERMIND_SYNCCONFIG_SNAPSYNC=true
      - NETHERMIND_SYNCCONFIG_FASTBLOCKS=true
      - NETHERMIND_SYNCCONFIG_DOWNLOADBODIESINFASTSYNC=true
      - NETHERMIND_SYNCCONFIG_DOWNLOADRECEIPTSINFASTSYNC=true
    logging:
      options:
        max-size: "1000m"
    labels:
      - "traefik.enable=true"
      - "traefik.http.middlewares.nethermind-goerli-stripprefix.stripprefix.prefixes=/nethermind-goerli"
      - "traefik.http.services.nethermind-goerli.loadbalancer.server.port=8545"
      - "traefik.http.routers.nethermind-goerli.entrypoints=websecure"
      - "traefik.http.routers.nethermind-goerli.tls.certresolver=myresolver"
      - "traefik.http.routers.nethermind-goerli.rule=Host(`$DOMAIN`) && PathPrefix(`/nethermind-goerli`)"
      - "traefik.http.routers.nethermind-goerli.middlewares=nethermind-goerli-stripprefix, ipwhitelist"
      - "prometheus-scrape.enabled=true"
      - "prometheus-scrape.port=9091"
      - "prometheus-scrape.job_name=nethermind-goerli"
      

  lighthouse-goerli:
    image: sigp/lighthouse:v4.0.1-rc.0-modern
    restart: unless-stopped
    networks:
      - chains
    ports:
      - 49742:49742/tcp # p2p
      - 49742:49742/udp # p2p
    expose:
      - 5054 # metrics
      - 4000 # http
      - 49742 # p2p
    volumes:
      - goerli_consensus:/data
      - .jwtsecret:/jwt.hex
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    command: |
      lighthouse
      beacon_node
      --network=goerli
      --disable-upnp
      --datadir=/data
      --port=49742
      --http
      --http-address=0.0.0.0
      --http-port=4000
      --target-peers=50
      --execution-endpoint=http://nethermind-goerli: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://beaconstate-goerli.chainsafe.io
    labels:
      - "prometheus-scrape.enabled=true"
      - "prometheus-scrape.port=5054"
      - "prometheus-scrape.job_name=lighthouse-goerli"
      - "prometheus-scrape.metrics_path=/metrics"
      - "traefik.enable=true"
      - "traefik.http.middlewares.lighthouse-goerli-stripprefix.stripprefix.prefixes=/lighthouse-goerli"
      - "traefik.http.services.lighthouse-goerli.loadbalancer.server.port=4000"
      - "traefik.http.routers.lighthouse-goerli.entrypoints=websecure"
      - "traefik.http.routers.lighthouse-goerli.tls.certresolver=myresolver"
      - "traefik.http.routers.lighthouse-goerli.rule=Host(`$DOMAIN`) && PathPrefix(`/lighthouse-goerli`)"
      - "traefik.http.routers.lighthouse-goerli.middlewares=lighthouse-goerli-stripprefix, ipwhitelist"


volumes:
  nethermind_goerli_db:
  nethermind_goerli_keystore:
  nethermind_goerli_logs:
  goerli_consensus:
