diff --git a/README.md b/README.md index 0b7c790..fcb914d 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/docker-compose-example/.env_template b/docker-compose-example/.env_template index df1c6cb..e5295bd 100644 --- a/docker-compose-example/.env_template +++ b/docker-compose-example/.env_template @@ -1,6 +1,6 @@ # Rename to .env -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 \ No newline at end of file +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="" # If set, serve publicly with tailscale funnel \ No newline at end of file diff --git a/docker-compose-example/docker-compose.yml b/docker-compose-example/docker-compose.yml index c765915..446e477 100644 --- a/docker-compose-example/docker-compose.yml +++ b/docker-compose-example/docker-compose.yml @@ -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: diff --git a/image/start.sh b/image/start.sh index ae11593..620fca9 100644 --- a/image/start.sh +++ b/image/start.sh @@ -8,13 +8,14 @@ until tailscale up --authkey="${TS_AUTHKEY}" --hostname="${TS_HOSTNAME}"; do done tailscale status if [ -n "${TS_SERVE_PORT}" ]; then - 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}" + 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 fi wait ${PID} diff --git a/k8s-example/deployment.yaml b/k8s-example/deployment.yaml index 1a5a9cd..67ebfa8 100644 --- a/k8s-example/deployment.yaml +++ b/k8s-example/deployment.yaml @@ -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"