Skip to content

Instantly share code, notes, and snippets.

@j0sh
Last active March 7, 2024 00:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save j0sh/b1971bfbbffeb92709cf096fb788f70c to your computer and use it in GitHub Desktop.
Save j0sh/b1971bfbbffeb92709cf096fb788f70c to your computer and use it in GitHub Desktop.
Passing tunnel tokens into cloudflared via Docker Compose secrets
services:
tunnel:
build:
dockerfile: Dockerfile.cloudflared
restart: unless-stopped
secrets:
- tunnel_prod_token
secrets:
tunnel_prod_token:
file: /path/to/tunnel/token
FROM busybox:1.36.1-uclibc as busybox
FROM cloudflare/cloudflared:2023.8.2
COPY --from=busybox /bin/sh /bin/sh
COPY --from=busybox /bin/cat /bin/cat
ENTRYPOINT [ "/bin/sh", "-c", "export TUNNEL_TOKEN=$(cat /run/secrets/tunnel_prod_token) ; cloudflared --no-autoupdate tunnel run" ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment