services:                             
  gnosis-erigon3-init:
    image: alpine:latest
    entrypoint: ["/bin/sh", "-c"]
    command: rm /datadir/nodekey
    volumes:
      - "${GNOSIS_MAINNET_ERIGON3_ARCHIVE_TRACE_DATA:-gnosis-mainnet-erigon3-archive-trace}:/datadir"
    init: true
  
  gnosis-erigon3:
    image: erigontech/erigon:${ERIGON3_VERSION:-v3.0.0-rc2}
    depends_on:
      - gnosis-erigon3-init
    user: root
    volumes:
      - "${GNOSIS_MAINNET_ERIGON3_ARCHIVE_TRACE_DATA:-gnosis-mainnet-erigon3-archive-trace}:/datadir"      
      - .jwtsecret:/jwtsecret
    expose:  
      - "20947"
      - "9090"
      - "8545"               
      - "8551"               
    ports: 
      - "20947:20947" 
      - "20947:20947/udp"
      - "28806:28806"
      - "28806:28806/udp"
      - "16393:16393"
      - "16393:16393/udp"
      - "17938:17938"
      - "17938:17938/udp"
    restart: unless-stopped
    command: >
      --chain=gnosis
      --prune.mode=archive
            --authrpc.addr=0.0.0.0
      --authrpc.vhosts=*
      --authrpc.jwtsecret=/jwtsecret
      --http
      --http.addr=0.0.0.0
      --http.port=8545
      --http.compression
      --http.vhosts='*'
      --http.corsdomain='*'
      --http.api=eth,debug,net,trace,web3,erigon
      --ws
      --ws.compression
      --rpc.gascap=300000000
      --metrics
      --metrics.addr=0.0.0.0
      --metrics.port=6060
      --bodies.cache=5G
      --rpc.batch.limit=200000
      --batchSize=2048MB
      --port=20947
      --datadir=/datadir
      --ethash.dagdir=/datadir/ethash
      --rpc.returndata.limit=1000000
      --p2p.protocol=66
      --p2p.protocol 67
      --p2p.protocol 68
      --p2p.allowed-ports 28806
      --p2p.allowed-ports 16393
      --p2p.allowed-ports 17938
      --nat extip:${IP}
    stop_grace_period: 1m
    environment:
      - "IP=${IP}"
    labels:                                      
      - "traefik.enable=true"                                                                         
      - "traefik.http.middlewares.gnosis-mainnet-erigon3-archive-trace-stripprefix.stripprefix.prefixes=/gnosis-erigon"
      - "traefik.http.services.gnosis-mainnet-erigon3-archive-trace.loadbalancer.server.port=8545"                    
      - "${NO_SSL:-traefik.http.routers.gnosis-mainnet-erigon3-archive-trace.entrypoints=websecure}"
      - "${NO_SSL:-traefik.http.routers.gnosis-mainnet-erigon3-archive-trace.tls.certresolver=myresolver}"
      - "${NO_SSL:-traefik.http.routers.gnosis-mainnet-erigon3-archive-trace.rule=Host(`$DOMAIN`) && PathPrefix(`/gnosis-erigon`)}"
      - "${NO_SSL:+traefik.http.routers.gnosis-mainnet-erigon3-archive-trace.rule=PathPrefix(`/gnosis-erigon`)}"      
      - "traefik.http.routers.gnosis-mainnet-erigon3-archive-trace.middlewares=gnosis-mainnet-erigon3-archive-trace-stripprefix, ipwhitelist"
    networks:   
      - chains        
      
volumes:
  gnosis-mainnet-erigon3-archive-trace:

