version: '3.1'

# Client https://github.com/NethermindEth/nethermind
# Nethermind container as in https://github.com/gnosischain/documentation/blob/a46e0964c7e4f75bed0ff02f7ae157c4417f60bd/docs/node/execution-layer-validator.md#setup-as-archive-node
# Beaconchain container as in https://github.com/gnosischain/lighthouse-launch

services:
  xdai-archive:
    hostname: xdai-archive
    image: nethermindeth/nethermind:1.15.0
    restart: always
    stop_grace_period: 1m
    command: |
      --JsonRpc.Enabled=true
      --JsonRpc.Host=0.0.0.0
      --JsonRpc.JwtSecretFile=/jwt.hex
      --JsonRpc.EngineHost=0.0.0.0
      --JsonRpc.EnginePort=8551
      --Metrics.Enabled=true
      --TraceStore.Enabled=true
      --TraceStore.BlocksToKeep=0
      --TraceStore.TraceTypes=Trace,Rewards
      --Sync.FastSync=false
    ports:
      - '10652:10652/tcp' # p2p
      - '10652:10652/udp' # p2p
    networks:
      - chains
    volumes:
      - nethermind_db:/nethermind/nethermind_db
      - nethermind_keystore:/nethermind/keystore
      - nethermind_logs:/nethermind/logs
      - .jwtsecret:/jwt.hex
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    environment:
      - NETHERMIND_CONFIG=xdai_archive
      - NETHERMIND_JSONRPCCONFIG_ENGINEENABLEDMODULES=[Eth,AccountAbstraction,Subscribe,TxPool,Web3,Personal,Proof,Net,Parity,Health,Trace]
      - NETHERMIND_METRICSCONFIG_EXPOSEPORT=9091
      - NETHERMIND_NETWORKCONFIG_P2PPORT=10652
      - NETHERMIND_NETWORKCONFIG_MAXACTIVEPEERS=150
    logging:
      options:
        max-size: "1000m"
    labels:
      - "traefik.enable=true"
      - "traefik.http.middlewares.xdai-archive-stripprefix.stripprefix.prefixes=/gnosis-archive"
      - "traefik.http.services.xdai-archive.loadbalancer.server.port=8545"
      - "traefik.http.routers.xdai-archive.entrypoints=websecure"
      - "traefik.http.routers.xdai-archive.tls.certresolver=myresolver"
      - "traefik.http.routers.xdai-archive.rule=Host(`$DOMAIN`) && PathPrefix(`/gnosis-archive`)"
      - "traefik.http.routers.xdai-archive.middlewares=xdai-archive-stripprefix, ipwhitelist"
      - "prometheus-scrape.enabled=true"
      - "prometheus-scrape.port=9091"
      - "prometheus-scrape.job_name=nethermind-xdai"
      

  lighthouse-gnosis:
    image: sigp/lighthouse:latest-modern
    restart: unless-stopped
    networks:
      - chains
    ports:
      - 46763:46763/tcp # p2p
      - 46763:46763/udp # p2p
    expose:
      - 5054 # metrics
      - 4000 # http
      - 46763 # p2p
    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=46763
      --http
      --http-address=0.0.0.0
      --http-port=4000
      --target-peers=50
      --execution-endpoint=http://xdai-archive: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/
    labels:
      - "prometheus-scrape.enabled=true"
      - "prometheus-scrape.port=5054"
      - "prometheus-scrape.job_name=lighthouse-gnosis"
      - "prometheus-scrape.metrics_path=/metrics"
      - "traefik.enable=true"
      - "traefik.http.middlewares.lighthouse-gnosis-stripprefix.stripprefix.prefixes=/lighthouse-gnosis"
      - "traefik.http.services.lighthouse-gnosis.loadbalancer.server.port=4000"
      - "traefik.http.routers.lighthouse-gnosis.entrypoints=websecure"
      - "traefik.http.routers.lighthouse-gnosis.tls.certresolver=myresolver"
      - "traefik.http.routers.lighthouse-gnosis.rule=Host(`$DOMAIN`) && PathPrefix(`/lighthouse-gnosis`)"
      - "traefik.http.routers.lighthouse-gnosis.middlewares=lighthouse-gnosis-stripprefix, ipwhitelist"


volumes:
  nethermind_db:
  nethermind_keystore:
  nethermind_logs:
  xdai_consensus:
