version: '3.1'

services:

  erigon-bsc:
    image: thorax/erigon:devel
    command: erigon --chain bsc --metrics --metrics.addr=0.0.0.0 --metrics.port=6060 --private.api.addr=0.0.0.0:9090 --pprof --pprof.addr=0.0.0.0 --pprof.port=6061
    volumes:
      - erigon-bsc-volume:/home/erigon/.local/share/erigon
    ports:
      - "30333:30303/tcp"
      - "30333:30303/udp"
      - "30304:30304/tcp"
      - "30304:30304/udp"
    networks:
      - chains
    restart: unless-stopped

  rpcdaemon-bsc:
    image: thorax/erigon:devel
    command: rpcdaemon --datadir=/home/erigon/.local/share/erigon --private.api.addr=erigon:9090 --http.addr=0.0.0.0 --http.vhosts=* --http.corsdomain=* --http.api=eth,debug,net --ws
    pid: service:erigon-bsc # Use erigon's PID namespace. It's required to open Erigon's DB from another process (RPCDaemon local-mode)
    volumes:
      - erigon-bsc-volume:/home/erigon/.local/share/erigon
    expose:
      - "8545"
    networks:
      - chains
    restart: unless-stopped
    labels:
      - "traefik.enable=true"
      - "traefik.http.middlewares.rpcdaemon-bsc-stripprefix.stripprefix.prefixes=/erigon-bsc"
      - "traefik.http.services.rpcdaemon-bsc.loadbalancer.server.port=8545"
      - "traefik.http.routers.rpcdaemon-bsc.entrypoints=websecure"
      - "traefik.http.routers.rpcdaemon-bsc.tls.certresolver=myresolver"
      - "traefik.http.routers.rpcdaemon-bsc.rule=Host(`$DOMAIN`) && PathPrefix(`/erigon-bsc`)"
      - "traefik.http.routers.rpcdaemon-bsc.middlewares=rpcdaemon-bsc-stripprefix, ipwhitelist"

volumes:
  erigon-bsc-volume: