Add --tailscale flag to bin/dev for remote access (#2168)

Enables sharing dev sites over Tailscale serve. Uses port convention
4xxxx (prepending 4 to the dev port, echoing TLS 443) so multiple apps
can run simultaneously on different ports.

Usage: bin/dev --tailscale
This commit is contained in:
Jeremy Daer
2025-12-16 09:54:53 -08:00
committed by GitHub
parent 97ffe00672
commit bf6ddcb933
+33 -4
View File
@@ -1,8 +1,13 @@
#!/usr/bin/env sh
bin/rails runner - <<EOF
puts "Login with david@example.com to: http://fizzy.localhost:3006/"
EOF
PORT=3006
USE_TAILSCALE=0
for arg in "$@"; do
case $arg in
--tailscale) USE_TAILSCALE=1 ;;
esac
done
if [ ! -f tmp/solid-queue.txt ]; then
export SOLID_QUEUE_IN_PUMA=false
@@ -12,4 +17,28 @@ if [ -f tmp/oss-config.txt ]; then
export OSS_CONFIG=1
fi
exec ./bin/rails server -p 3006
if [ "$USE_TAILSCALE" = "1" ]; then
if ! command -v tailscale >/dev/null 2>&1; then
echo "Error: tailscale not found" >&2
exit 1
fi
TS_STATUS=$(tailscale status --self --json 2>&1)
if [ $? -ne 0 ]; then
echo "Error: tailscale not logged in" >&2
exit 1
fi
TS_HOSTNAME=$(echo "$TS_STATUS" | jq -r '.Self.DNSName | rtrimstr(".")')
TS_PORT="4$PORT"
stop_tailscale() { tailscale serve --https=$TS_PORT off >/dev/null 2>&1; }
trap stop_tailscale EXIT INT TERM
tailscale serve --bg --https=$TS_PORT "http://fizzy.localhost:$PORT" >/dev/null 2>&1
echo "Login with david@example.com to: https://$TS_HOSTNAME:$TS_PORT/"
else
echo "Login with david@example.com to: http://fizzy.localhost:$PORT/"
fi
./bin/rails server -p $PORT