version: '3.1'

services:

  dshackle:
    image: emeraldpay/dshackle:0.13.1
    restart: unless-stopped
    volumes:
      - ./dshackle/config:/etc/dshackle # This should hold all your yaml files
    expose:
      - 8080 # /eth
      - 8081 # /metrics
      - 8082 # healthcheck
      - 2449 # grpc
    networks:
      - chains
    ports:
      - "127.0.0.1:8082:8082" # healthcheck
    environment:
      - ALCHEMY_KEY=${ALCHEMY_KEY}
      - ANYBLOCK_KEY=${ANYBLOCK_KEY}
      - CHAINSTACK_NODE=${CHAINSTACK_NODE}
      - CHAINSTACK_USERNAME=${CHAINSTACK_USERNAME}
      - CHAINSTACK_PASSWORD=${CHAINSTACK_PASSWORD}
      - COINBASE_USERNAME=${COINBASE_USERNAME}
      - COINBASE_PASSWORD=${COINBASE_PASSWORD}
      - INFURA_KEY=${INFURA_KEY}
      - RIVET_KEY=${RIVET_KEY}
      - QUICKNODE_HTTP=${QUICKNODE_HTTP}
      - QUICKNODE_WSS=${QUICKNODE_WSS}
    labels:
      - "prometheus-scrape.enabled=true"
      - "prometheus-scrape.port=8081"
      - "prometheus-scrape.job_name=dshackle"
      - "prometheus-scrape.metrics_path=/metrics"
      - "traefik.enable=true"
      - "traefik.http.middlewares.dshackle-stripprefix.stripprefix.prefixes=/dshackle"
      #      - "traefik.http.middlewares.shackle-replacepath.replacepath.path=/eth"
      - "traefik.http.services.dshackle.loadbalancer.server.port=8080"
      - "traefik.http.routers.dshackle.entrypoints=websecure"
      - "traefik.http.routers.dshackle.tls.certresolver=myresolver"
      - "traefik.http.routers.dshackle.rule=Host(`$DOMAIN`) && PathPrefix(`/dshackle`)"
      #      - "traefik.http.routers.dshackle.middlewares=dshackle-stripprefix, dshackle-replacepath, ipwhitelist"
      - "traefik.http.routers.dshackle.middlewares=dshackle-stripprefix, ipwhitelist"

  redis:
    image: healthcheck/redis:alpine
    restart: unless-stopped
    networks:
      - chains
    environment:
      - REDIS_RAM=${REDIS_RAM}
    command:
      - "redis-server"
      - "--maxmemory ${REDIS_RAM}"
      - "--maxmemory-policy allkeys-lru"
      - '--save ""'



