name: Traefik
services:
  traefik:
    image: traefik:v3.0
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ../certs:/etc/traefik/certs:ro
      - ./config/dynamic:/etc/traefik/dynamic:ro           # dossier des .yml
    command:
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.websecure.address=:443"     # ← HTTPS
      - "--entrypoints.web.address=:80"
      - "--entrypoints.web.http.redirections.entryPoint.to=websecure"
      - "--entrypoints.web.http.redirections.entryPoint.scheme=https"
      - "--entrypoints.web.http.redirections.entryPoint.permanent=true"
      - "--api.insecure=false"
      - "--log.level=DEBUG"
      - "--providers.file.directory=/etc/traefik/dynamic"
      - "--providers.file.watch=true"
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.dashboard.rule=Host(`${SERVER_NAME}`)"
      - "traefik.http.routers.dashboard.entrypoints=websecure"
      - "traefik.http.routers.dashboard.tls=true"
      - "traefik.http.routers.dashboard.service=api@internal"
      - "traefik.http.routers.dashboard.middlewares=auth"
      - traefik.http.middlewares.auth.basicauth.users=${BASICAUTH:-""}
    networks:
      - mozart-network
networks:
  mozart-network:
    external: true