version: '3.1'

services:
  erigon-polygon:
    build:
      args:
        ERIGON_VERSION: v2.37.0
        ERIGON_REPOSITORY: https://github.com/ledgerwatch/erigon.git
      context: ./polygon/erigon
      dockerfile: Dockerfile
    environment:
      - SNAPSHOT_URL=https://matic-blockchain-snapshots.s3-accelerate.amazonaws.com/matic-mainnet/erigon-archive-snapshot-2022-12-13.tar.gz
      - BOOTSTRAP=1
      - HEIMDALLD=${HEIMDALLD:-http://heimdalld:26657}
      - HEIMDALLR=${HEIMDALLR:-http://heimdallr:1317}
    volumes:
      - "polygon-archive_data:/datadir"
    expose:
      - "16630"
      - "9090"
      - "8545"
      - "8551"
    ports:
      - "27113:27113"
      - "27113:27113/udp"
    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-polygon-stripprefix.stripprefix.prefixes=/polygon-archive"
      - "traefik.http.services.erigon-polygon.loadbalancer.server.port=8545"
      - "traefik.http.routers.erigon-polygon.entrypoints=websecure"
      - "traefik.http.routers.erigon-polygon.tls.certresolver=myresolver"
      - "traefik.http.routers.erigon-polygon.rule=Host(`$DOMAIN`) && PathPrefix(`/polygon-archive`)"
      - "traefik.http.routers.erigon-polygon.middlewares=erigon-polygon-stripprefix, ipwhitelist"
    networks:
      - chains

volumes:
    polygon-archive_data:
