use TS_FUNNEL as boolean to enable funnel on TS_SERVE_PORT

This commit is contained in:
John Bowdre 2023-12-29 13:43:50 -06:00
parent fe4cba9c4f
commit d3ca767b8a
5 changed files with 17 additions and 16 deletions

View file

@ -22,7 +22,7 @@ Expected environment variables:
| `TS_STATEDIR` | `/var/lib/tailscale/` | required directory for storing Tailscale state, this should be mounted to the container for persistence |
| `TS_OPT` | `--verbose=1` | optional additional [flags](https://tailscale.com/kb/1278/tailscaled#flags-to-tailscaled) for `tailscaled` |
| `TS_SERVE_PORT` | `8080` | optional application port to expose with [Tailscale Serve](https://tailscale.com/kb/1312/serve) |
| `TS_FUNNEL_PORT` | `8080` | optional application port to expose **publicly** with [Tailscale Funnel](https://tailscale.com/kb/1223/funnel) |
| `TS_FUNNEL` | `1` | if set (to anything), will proxy `TS_SERVE_PORT` **publicly** with [Tailscale Funnel](https://tailscale.com/kb/1223/funnel) |
You can drop these in a `.env` file alongside your `docker-compose.yml` to load them automatically - see [.env_template](/docker-compose-example/env_template) for an example.

View file

@ -3,4 +3,4 @@ TS_AUTHKEY="" # Required Tailscale auth key
TS_HOSTNAME="" # Optional hostname for this node
TS_OPT="" # Optional additional arguments for tailscaled
TS_SERVE_PORT="" # Optional backend port to proxy with tailscale serve
TS_FUNNEL_PORT="" # Optional backend port to publish with tailscale funnel
TS_FUNNEL="" # If set, serve publicly with tailscale funnel

View file

@ -8,7 +8,7 @@ services:
TS_HOSTNAME: ${TS_HOSTNAME:-ts-docker}
TS_STATEDIR: "/var/lib/tailscale/" # store ts state in a local volume
TS_SERVE_PORT: ${TS_SERVE_PORT:-} # optional port to proxy with tailscale serve (ex: '80')
TS_FUNNEL_PORT: ${TS_FUNNEL_PORT:-} # optional port to publish publicly with tailscale funnel (ex: '80')
TS_FUNNEL: ${TS_FUNNEL:-} # if set, serve publicly with tailscale funnel
volumes:
- ./ts_data:/var/lib/tailscale/
myservice:

View file

@ -8,13 +8,14 @@ until tailscale up --authkey="${TS_AUTHKEY}" --hostname="${TS_HOSTNAME}"; do
done
tailscale status
if [ -n "${TS_SERVE_PORT}" ]; then
if [ -n "${TS_FUNNEL}" ]; then
if ! tailscale funnel status | grep -q -A1 '(Funnel on)' | grep -q "${TS_SERVE_PORT}"; then
tailscale funnel --bg "${TS_SERVE_PORT}"
fi
else
if ! tailscale serve status | grep -q "${TS_SERVE_PORT}"; then
tailscale serve --bg "${TS_SERVE_PORT}"
fi
fi
if [ -n "${TS_FUNNEL_PORT}" ]; then
if ! tailscale funnel status | grep -q -A1 '(Funnel on)' | grep -q "${TS_FUNNEL_PORT}"; then
tailscale funnel --bg "${TS_FUNNEL_PORT}"
fi
fi
wait ${PID}

View file

@ -23,8 +23,8 @@ spec:
value: "/var/lib/tailscale"
- name: TS_SERVE_PORT
value: "${TS_SERVE_PORT:-}"
- name: TS_FUNNEL_PORT
value: "${TS_FUNNEL_PORT:-}"
- name: TS_FUNNEL
value: "${TS_FUNNEL:-}"
resources:
limits:
memory: "128Mi"