services:
  traefik:
    image: traefik:v3.3
    container_name: traefik
    restart: unless-stopped

    command:
      - --global.checknewversion=true
      - --global.sendanonymoususage=false

      - --api.dashboard=true
      - --api.insecure=false

      - --log.level=INFO

      - --providers.docker=true
      - --providers.docker.endpoint=unix:///var/run/docker.sock
      - --providers.docker.exposedbydefault=false
      - --providers.docker.network=frontend_net

      - --entrypoints.web.address=:80
      - --entrypoints.websecure.address=:443

      - --certificatesresolvers.cloudflare.acme.email=michideheld@gmx.de
      - --certificatesresolvers.cloudflare.acme.storage=/letsencrypt/acme.json
      - --certificatesresolvers.cloudflare.acme.dnschallenge=true
      - --certificatesresolvers.cloudflare.acme.dnschallenge.provider=cloudflare

    environment:
      TZ: Europe/Berlin
      CF_DNS_API_TOKEN_FILE: /run/secrets/cloudflare_dns_api_token

    secrets:
      - cloudflare_dns_api_token

    ports:
      - "80:80"
      - "443:443"

    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - /mnt/user/appdata/traefik/acme.json:/letsencrypt/acme.json

    networks:
      - frontend_net

    labels:
      - traefik.enable=true
      - traefik.docker.network=frontend_net
      - traefik.http.routers.traefik.rule=Host(`traefik.kaleschke.info`)
      - traefik.http.routers.traefik.entrypoints=websecure
      - traefik.http.routers.traefik.tls=true
      - traefik.http.routers.traefik.tls.certresolver=cloudflare
      - traefik.http.routers.traefik.service=api@internal

secrets:
  cloudflare_dns_api_token:
    file: /mnt/user/appdata/traefik/secrets/cloudflare_dns_api_token

networks:
  frontend_net:
    external: true