diff --git a/README.md b/README.md index 93e7852..d351a2a 100644 --- a/README.md +++ b/README.md @@ -15,5 +15,4 @@ A nginx layer is added. It manages two services in independent containers at loc ## TODO -- auth key as a secret -- force reuse hostname in tailscale instead of adding suffix. Example: first start is assigned `hostname`. Then, if container is recreated, Tailscale assigns `hostname-1` \ No newline at end of file +- force reuse hostname in tailscale instead of adding suffix. Example: first container is assigned `hostname`. Then, if container is recreated, Tailscale assigns `hostname-1`. Possibly helpful [info](https://tailscale.com/kb/1111/ephemeral-nodes/#can-i-create-an-ephemeral-node-without-an-auth-key). \ No newline at end of file diff --git a/complex-example/docker-compose.yml b/complex-example/docker-compose.yml index e26e6c7..60f327c 100644 --- a/complex-example/docker-compose.yml +++ b/complex-example/docker-compose.yml @@ -3,6 +3,8 @@ services: tailscale: build: context: ./tailscale + environment: + - TAILSCALE_AUTH_KEY nginx: build: context: ./nginx diff --git a/complex-example/tailscale/start.sh b/complex-example/tailscale/start.sh index 5de2d3f..2692224 100644 --- a/complex-example/tailscale/start.sh +++ b/complex-example/tailscale/start.sh @@ -1,7 +1,9 @@ #!/bin/ash echo "Starting TS daemon" tailscaled --tun=userspace-networking & -sleep 5 -tailscale up --authkey=TAILSCALE_AUTH_KEY --hostname=complex-example +PID=$! +until tailscale up --authkey=${TAILSCALE_AUTH_KEY} --hostname=complex-example; do + sleep 0.1 +done tailscale status -sleep infinity \ No newline at end of file +wait ${PID} \ No newline at end of file diff --git a/simple-example/docker-compose.yml b/simple-example/docker-compose.yml index f29d145..2634837 100644 --- a/simple-example/docker-compose.yml +++ b/simple-example/docker-compose.yml @@ -3,6 +3,8 @@ services: tailscale: build: context: ./tailscale + environment: + - TAILSCALE_AUTH_KEY some-service-1: image: nginxdemos/hello network_mode: "service:tailscale" diff --git a/simple-example/tailscale/start.sh b/simple-example/tailscale/start.sh index 5e42e1c..2692224 100644 --- a/simple-example/tailscale/start.sh +++ b/simple-example/tailscale/start.sh @@ -1,7 +1,9 @@ #!/bin/ash echo "Starting TS daemon" tailscaled --tun=userspace-networking & -sleep 5 -tailscale up --authkey=TAILSCALE_AUTH_KEY --hostname=simple-docker-compose +PID=$! +until tailscale up --authkey=${TAILSCALE_AUTH_KEY} --hostname=complex-example; do + sleep 0.1 +done tailscale status -sleep infinity \ No newline at end of file +wait ${PID} \ No newline at end of file