Created
December 9, 2024 23:15
-
-
Save carlosonunez/3dd4b65f370b6bacb9befb09f04b953f to your computer and use it in GitHub Desktop.
Docker image entrypoint provided for Tailscale ACL issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
TAILSCALE_HOSTNAME="${TAILSCALE_HOSTNAME:-test-$(date +%s)}" | |
verify_proxy_host_port_defined() { | |
for var in PROXY_HOST PROXY_PORT \ | |
TAILSCALE_AUTH_KEY TAILSCALE_EXIT_NODE_IP | |
do | |
test -n "${!var}" && continue | |
>&2 echo "Bootstrap env var not defined: $var" | |
return 1 | |
done | |
return 0 | |
} | |
connect_to_tailscale() { | |
proxy_server="${PROXY_HOST}:${PROXY_PORT}" | |
mkdir -p /tmp/tailscale | |
/var/runtime/tailscaled --tun=userspace-networking \ | |
--socks5-server="$proxy_server" & | |
/var/runtime/tailscale up \ | |
--authkey="$TAILSCALE_AUTH_KEY" \ | |
--hostname="$TAILSCALE_HOSTNAME" \ | |
--exit-node="$TAILSCALE_EXIT_NODE_IP" \ | |
--accept-routes | |
} | |
verify_proxy_host_port_defined || exit 1 | |
connect_to_tailscale || exit 1 | |
>&2 echo "INFO: Connected to Tailscale." | |
export TAILSCALE_PROXY="socks5://${PROXY_HOST}:${PROXY_PORT}" | |
if test -n "$RUN_LOCALLY" | |
then | |
exec "$@" | |
elif test -z "$AWS_LAMBDA_RUNTIME_API" | |
then | |
exec /usr/local/bin/aws_lambda_rie "$@" | |
else | |
exec "$@" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment