services:
  traefik:
    image: traefik:v3.6.1
    container_name: traefik
    restart: always
    expose:
      - "8082"
    ports:
      - "443:443"
      - "80:80"
      - "3042:3042"
    command:
      - "--api=true"
      - "--api.insecure=true"
      - "--api.dashboard=true"
      - "--log.level=info"
      - "--core.defaultRuleSyntax=v2"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--providers.file.filename=/dynamic_config.yml"
      - "--entrypoints.websecure.address=:443"
      # disable read timeout to not timeout webdav uploads. 
      # TODO:can this be local to the webdav container
      - "--entrypoints.websecure.transport.respondingTimeouts.readTimeout=0"
      - "--entrypoints.metrics.address=:8082"
      - "--entrypoints.grpc.address=:3042"
      - "--entrypoints.web.address=:80"
      - "--metrics.prometheus.entryPoint=metrics"
      - "${NO_SSL:---entrypoints.web.http.redirections.entryPoint.to=websecure}"
      - "${NO_SSL:---entrypoints.web.http.redirections.entryPoint.scheme=https}"
      - "${NO_SSL:---certificatesresolvers.myresolver.acme.tlschallenge=true}"
      - "${NO_SSL:---certificatesresolvers.myresolver.acme.email=$EMAIL}"
      - "${NO_SSL:---certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json}"
    volumes:
      - "./traefik/letsencrypt:/letsencrypt"
      - "./main_configs:/main_configs"
      - "./traefik/config/dynamic_config.yml:/dynamic_config.yml"
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
    networks:
      - chains
    labels:
      - "traefik.enable=true"
      - "traefik.http.middlewares.ipallowlist.ipallowlist.sourcerange=$WHITELIST"
      - "prometheus-scrape.enabled=true"
      - "prometheus-scrape.port=8082"
      - "prometheus-scrape.job_name=traefik"
    logging:
      options:
        max-file: '1'
        compress: 'false'
      driver: local
