tunnel-with-dependency.yaml 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # process-compose.yaml — Cloudflare tunnel exposing a local service
  2. #
  3. # Pattern: A web service + a Cloudflare tunnel that forwards external
  4. # traffic to it. The tunnel must depend on the service being HEALTHY,
  5. # not just started, to avoid Cloudflare seeing repeated connection
  6. # refused errors during service warmup.
  7. version: "0.5"
  8. processes:
  9. internal-svc:
  10. command: "myservice serve --port 8000"
  11. working_dir: "X:/path/to/myservice"
  12. readiness_probe:
  13. http_get:
  14. host: localhost
  15. port: 8000
  16. path: /
  17. initial_delay_seconds: 5
  18. period_seconds: 15
  19. timeout_seconds: 3
  20. failure_threshold: 3
  21. availability:
  22. restart: always
  23. backoff_seconds: 3
  24. max_restarts: 20
  25. log_location: "logs/internal-svc.log"
  26. tunnel:
  27. # Single-quoted YAML string with embedded paths-with-spaces.
  28. # Tunnel UUID + cert paths should come from a gitignored .env.
  29. command: '"C:/Program Files (x86)/cloudflared/cloudflared.exe" tunnel --origincert C:/Users/me/.cloudflared/cert.pem --credentials-file C:/Users/me/.cloudflared/<TUNNEL_UUID>.json run --url http://localhost:8000 my-tunnel'
  30. working_dir: "C:/Users/me/.cloudflared"
  31. depends_on:
  32. internal-svc:
  33. condition: process_healthy # Critical: don't open tunnel until service is ready
  34. availability:
  35. restart: always
  36. backoff_seconds: 5
  37. max_restarts: 50 # Tunnels can disconnect; allow many retries
  38. log_location: "logs/tunnel.log"