version: '3.1'                                                                                                                                                                                              
                                                                                                                                                                                                            
services:                                                                                             
  erigon-mainnet:    
    image: thorax/erigon:v2.48.1
    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
      --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"

      
  fireeth-mainnet:
    build:
      context: ./firehose-mainnet/
    command: -c /etc/firehose/config.yml start
    environment:
      - "ETHEREUM_ARCHIVE_RPC=http://erigon-mainnet:8545"
    expose:
      - 8545 # geth rpc
      - 8551 # consensus client
      - 13042 # firehose grpc
    ports:
      - "24465:24465"
      - "24465:24465/udp"
      #- "13042:13042"
    labels:
      - "traefik.enable=true"
      - "traefik.http.services.firehose-mainnet.loadbalancer.server.scheme=h2c"
      - "traefik.http.services.firehose-mainnet.loadbalancer.server.port=13042"
      - "traefik.http.routers.firehose-mainnet.entrypoints=grpc"
      #- "traefik.http.routers.firehose-mainnet.tls.certresolver=myresolver"
      - "traefik.http.routers.firehose-mainnet.rule=Host(`firehose-mainnet.$DOMAIN`)"
      - "traefik.http.routers.firehose-mainnet.middlewares=ipwhitelist"      
    networks:
      - chains
    volumes:
      - "./firehose-mainnet/config.yml:/etc/firehose/config.yml"
      - "geth-mainnet_data:/var/lib/geth"
      - "firehose-mainnet_data:/var/lib/firehose"
      - ".jwtsecret:/jwtsecret"
    restart: unless-stopped
    stop_grace_period: 1m


  lighthouse-erigon-mainnet:
    image: sigp/lighthouse:latest-modern
    ports:
      - "18719:18719"
      - "18719:18719/udp"
    volumes:
      - .jwtsecret:/jwtsecret
      - lighthouse-erigon-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-mainnet.beaconcha.in
      --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-erigon-mainnet-stripprefix.stripprefix.prefixes=/lighthouse-erigon-mainnet"
      - "traefik.http.services.lighthouse-erigon-mainnet.loadbalancer.server.port=5052"
      - "traefik.http.routers.lighthouse-erigon-mainnet.entrypoints=websecure"
      - "traefik.http.routers.lighthouse-erigon-mainnet.tls.certresolver=myresolver"
      - "traefik.http.routers.lighthouse-erigon-mainnet.rule=Host(`$DOMAIN`) && PathPrefix(`/lighthouse-erigon-mainnet`)"
      - "traefik.http.routers.lighthouse-erigon-mainnet.middlewares=lighthouse-erigon-mainnet-stripprefix, ipwhitelist"

      
  lighthouse-fireeth-mainnet:
    image: sigp/lighthouse:latest-modern
    ports:
      - "55031:55031"
      - "55031:55031/udp"
    volumes:
      - .jwtsecret:/jwtsecret
      - lighthouse-fireeth-mainnet_data:/root/.lighthouse
    command: >
      lighthouse beacon_node
      --eth1-endpoints http://fireeth-mainnet:8545
      --execution-endpoint http://fireeth-mainnet:8551
      --execution-jwt /jwtsecret
      --checkpoint-sync-url https://mainnet-checkpoint-sync.attestant.io
      --http
      --http-address 0.0.0.0
      --port 55031
    restart: unless-stopped
    stop_grace_period: 1m
    networks:
      - chains
    labels:
      - "traefik.enable=true"
      - "traefik.http.middlewares.lighthouse-fireeth-mainnet-stripprefix.stripprefix.prefixes=/lighthouse-fireeth-mainnet"
      - "traefik.http.services.lighthouse-fireeth-mainnet.loadbalancer.server.port=5052"
      - "traefik.http.routers.lighthouse-fireeth-mainnet.entrypoints=websecure"
      - "traefik.http.routers.lighthouse-fireeth-mainnet.tls.certresolver=myresolver"
      - "traefik.http.routers.lighthouse-fireeth-mainnet.rule=Host(`$DOMAIN`) && PathPrefix(`/lighthouse-fireeth-mainnet`)"
      - "traefik.http.routers.lighthouse-fireeth-mainnet.middlewares=lighthouse-fireeth-mainnet-stripprefix, ipwhitelist"


volumes:
    erigon-mainnet:
    lighthouse-fireeth-mainnet_data:
    lighthouse-erigon-mainnet_data:
    geth-mainnet_data:
    firehose-mainnet_data:
