services:
  proxy:
    image: traefik:v3.7.11-windowsservercore-ltsc2022
    restart: unless-stopped
    depends_on:
      httpbin:
        condition: service_started
    healthcheck:
      test: [ "CMD", "traefik" ,"healthcheck", "--ping" ]
      interval: 10s
      timeout: 10s
      retries: 10
    ports:
      - target: 8888
        published: 8888
        protocol: tcp
        mode: host
      - target: 4443
        published: 4443
        protocol: tcp
        mode: host
      - target: 4443
        published: 4443
        protocol: udp
        mode: host
      - target: 9999
        published: 9999
        protocol: tcp
        mode: host
      - target: 8754
        published: 8754
        protocol: tcp
        mode: host
    volumes:
      - type: npipe
        source: \\.\pipe\docker_engine
        target: \\.\pipe\docker_engine
      - ./traefik:c:/certs
    command:
      # Enable Docker in Traefik, so that it reads labels from Docker services
      - --providers.docker
      - --providers.docker.endpoint=npipe:////./pipe/docker_engine
      # TLS providers
      - --providers.file.directory=c:/certs
      # Auto discovery
      - --providers.file.watch=true
      # Do not expose all Docker services, only the ones explicitly exposed
      - --providers.docker.exposedbydefault=false
      # Create an entrypoint "http" listening on port 8080
      - --entrypoints.http.address=:8888
      # Create an entrypoint "https" listening on port 4443
      - --entrypoints.https.address=:4443
      # Create alt-no-quic entrypoints
      - --entrypoints.alt-http.address=:9999
      - --entrypoints.alt-https.address=:8754
      # QUIC Related Configuration
      - --entrypoints.https.http3=true
      - --entrypoints.alt-https.http3=false
      # Enable the access log, with HTTP requests
      - --accesslog
      # Enable the Traefik log, for configurations and errors
      - --log
      # Disable the Dashboard and API
      - --api.dashboard=false
      # Enable healthcheck
      - --ping
      - --log.level=ERROR
      # Set auto Goaway send for testing purposes (HTTP/1 or HTTP/2)
      # Sadly unsupported for HTTP/3!
      - --entrypoints.alt-https.transport.keepAliveMaxTime=5s

  httpbin:
    image: jawah/httpbin:windows
    build:
      context: ./go-httpbin
      dockerfile: patched.Dockerfile
    restart: unless-stopped
    labels:
      - traefik.enable=true
      - traefik.http.routers.httpbin-http.rule=Host(`httpbin.local`) || Host(`alt.httpbin.local`)
      - traefik.http.routers.httpbin-http.entrypoints=http,alt-http
      - traefik.http.routers.httpbin-https.rule=Host(`httpbin.local`) || Host(`alt.httpbin.local`)
      - traefik.http.routers.httpbin-https.entrypoints=https,alt-https
      - traefik.http.routers.httpbin-https.tls=true
      - traefik.http.services.httpbin.loadbalancer.server.port=8080
