version: '3.1'

services:
  erigon-mainnet:
    image: thorax/erigon:v2.42.0
    expose:
      - "16630"
      - "9090"
      - "8545"
      - "8551"
    ports:
      - "16630:16630"
      - "16630:16630/udp"
    volumes:
      - erigon-mainnet:/home/erigon/.local/share/erigon
      - .jwtsecret:/jwtsecret
    networks:
      - chains
    command: >
      --chain mainnet
      --externalcl
      --port=16630
      --metrics --metrics.addr=0.0.0.0 --metrics.port=6060
      --private.api.addr=0.0.0.0:9090
      --torrent.upload.rate="1250mb"
      --torrent.download.rate="1250mb"
      --pprof
      --pprof.addr=0.0.0.0
      --pprof.port=6061
      --authrpc.addr=0.0.0.0
      --authrpc.vhosts=*
      --authrpc.jwtsecret=/jwtsecret
      --http.addr=0.0.0.0
      --http.vhosts=*
      --http.corsdomain=*
      --http.api=eth,erigon,web3,net,debug,trace,txpool
      --rpc.returndata.limit=1000000
      --rpc.gascap=5000000000
      --ws 
    restart: unless-stopped
    stop_grace_period: 1m
    labels:
      - "prometheus-scrape.enabled=true"
      - "prometheus-scrape.port=6060"
      - "prometheus-scrape.job_name=erigon"
      - "prometheus-scrape.metrics_path=/debug/metrics/prometheus"
      - "traefik.enable=true"
      - "traefik.http.middlewares.erigon-mainnet-stripprefix.stripprefix.prefixes=/erigon"
      - "traefik.http.services.erigon-mainnet.loadbalancer.server.port=8545"
      - "traefik.http.routers.erigon-mainnet.entrypoints=websecure"
      - "traefik.http.routers.erigon-mainnet.tls.certresolver=myresolver"
      - "traefik.http.routers.erigon-mainnet.rule=Host(`$DOMAIN`) && PathPrefix(`/erigon`)"
      - "traefik.http.routers.erigon-mainnet.middlewares=erigon-mainnet-stripprefix, ipwhitelist"
      
  lighthouse-mainnet:
    image: sigp/lighthouse:v4.0.1-modern
    ports:
      - "18719:18719"
      - "18719:18719/udp"      
      - "127.0.0.1:5052:5052"
    volumes:
      - .jwtsecret:/jwtsecret
      - lighthouse-mainnet_data:/root/.lighthouse
    command: >
      lighthouse beacon_node
      --eth1-endpoints http://erigon-mainnet:8545
      --execution-endpoint http://erigon-mainnet:8551
      --execution-jwt /jwtsecret
      --checkpoint-sync-url https://sync.invis.tools
      --http
      --http-address 0.0.0.0
      --port 18719
    restart: unless-stopped
    stop_grace_period: 1m
    networks:
      - chains
    labels:
      - "traefik.enable=true"
      - "traefik.http.middlewares.lighthouse-mainnet-stripprefix.stripprefix.prefixes=/lighthouse-mainnet"
      - "traefik.http.services.lighthouse-mainnet.loadbalancer.server.port=5052"
      - "traefik.http.routers.lighthouse-mainnet.entrypoints=websecure"
      - "traefik.http.routers.lighthouse-mainnet.tls.certresolver=myresolver"
      - "traefik.http.routers.lighthouse-mainnet.rule=Host(`$DOMAIN`) && PathPrefix(`/lighthouse-mainnet`)"
      - "traefik.http.routers.lighthouse-mainnet.middlewares=lighthouse-mainnet-stripprefix, ipwhitelist"

volumes:
    erigon-mainnet:
    lighthouse-mainnet_data:
