2021-01-20 16:55:05 +00:00
|
|
|
#!/usr/bin/env sh
|
|
|
|
|
|
|
|
#
|
|
|
|
# Runs `go build` with flags configured for docker distribution. All
|
|
|
|
# it does differently from `go build` is burn git commit and version
|
|
|
|
# information into the binaries inside docker, so that we can track down user
|
|
|
|
# issues.
|
|
|
|
#
|
|
|
|
############################################################################
|
|
|
|
#
|
2021-10-12 19:27:39 +00:00
|
|
|
# WARNING: Tailscale is not yet officially supported in container
|
|
|
|
# environments, such as Docker and Kubernetes. Though it should work, we
|
|
|
|
# don't regularly test it, and we know there are some feature limitations.
|
2021-01-20 16:55:05 +00:00
|
|
|
#
|
2021-10-12 19:27:39 +00:00
|
|
|
# See current bugs tagged "containers":
|
2021-01-20 16:55:05 +00:00
|
|
|
# https://github.com/tailscale/tailscale/labels/containers
|
|
|
|
#
|
|
|
|
############################################################################
|
|
|
|
|
|
|
|
set -eu
|
|
|
|
|
2022-01-04 00:53:36 +00:00
|
|
|
# Use the "go" binary from the "tool" directory (which is github.com/tailscale/go)
|
2024-03-08 23:24:36 +00:00
|
|
|
export PATH="$PWD"/tool:"$PATH"
|
2022-01-04 00:53:36 +00:00
|
|
|
|
2024-03-08 23:24:36 +00:00
|
|
|
eval "$(./build_dist.sh shellvars)"
|
2023-01-28 01:24:41 +00:00
|
|
|
|
|
|
|
DEFAULT_TARGET="client"
|
2022-01-03 18:09:00 +00:00
|
|
|
DEFAULT_TAGS="v${VERSION_SHORT},v${VERSION_MINOR}"
|
2023-12-11 07:03:18 +00:00
|
|
|
DEFAULT_BASE="tailscale/alpine-base:3.18"
|
2022-01-03 18:09:00 +00:00
|
|
|
|
|
|
|
PUSH="${PUSH:-false}"
|
2023-01-28 01:24:41 +00:00
|
|
|
TARGET="${TARGET:-${DEFAULT_TARGET}}"
|
2022-01-03 18:09:00 +00:00
|
|
|
TAGS="${TAGS:-${DEFAULT_TAGS}}"
|
|
|
|
BASE="${BASE:-${DEFAULT_BASE}}"
|
2024-01-10 19:19:20 +00:00
|
|
|
PLATFORM="${PLATFORM:-}" # default to all platforms
|
2021-01-20 16:55:05 +00:00
|
|
|
|
2022-12-13 17:40:41 +00:00
|
|
|
case "$TARGET" in
|
|
|
|
client)
|
2023-01-28 01:24:41 +00:00
|
|
|
DEFAULT_REPOS="tailscale/tailscale"
|
|
|
|
REPOS="${REPOS:-${DEFAULT_REPOS}}"
|
2022-12-13 17:40:41 +00:00
|
|
|
go run github.com/tailscale/mkctr \
|
|
|
|
--gopaths="\
|
|
|
|
tailscale.com/cmd/tailscale:/usr/local/bin/tailscale, \
|
|
|
|
tailscale.com/cmd/tailscaled:/usr/local/bin/tailscaled, \
|
|
|
|
tailscale.com/cmd/containerboot:/usr/local/bin/containerboot" \
|
|
|
|
--ldflags="\
|
2023-02-14 00:56:22 +00:00
|
|
|
-X tailscale.com/version.longStamp=${VERSION_LONG} \
|
|
|
|
-X tailscale.com/version.shortStamp=${VERSION_SHORT} \
|
|
|
|
-X tailscale.com/version.gitCommitStamp=${VERSION_GIT_HASH}" \
|
2022-12-13 17:40:41 +00:00
|
|
|
--base="${BASE}" \
|
|
|
|
--tags="${TAGS}" \
|
2024-04-17 16:11:57 +00:00
|
|
|
--gotags="ts_kube" \
|
2022-12-13 17:40:41 +00:00
|
|
|
--repos="${REPOS}" \
|
|
|
|
--push="${PUSH}" \
|
2024-01-10 19:19:20 +00:00
|
|
|
--target="${PLATFORM}" \
|
2022-12-13 17:40:41 +00:00
|
|
|
/usr/local/bin/containerboot
|
|
|
|
;;
|
|
|
|
operator)
|
2023-01-28 01:24:41 +00:00
|
|
|
DEFAULT_REPOS="tailscale/k8s-operator"
|
|
|
|
REPOS="${REPOS:-${DEFAULT_REPOS}}"
|
2022-12-13 17:40:41 +00:00
|
|
|
go run github.com/tailscale/mkctr \
|
|
|
|
--gopaths="tailscale.com/cmd/k8s-operator:/usr/local/bin/operator" \
|
|
|
|
--ldflags="\
|
2023-02-14 00:56:22 +00:00
|
|
|
-X tailscale.com/version.longStamp=${VERSION_LONG} \
|
|
|
|
-X tailscale.com/version.shortStamp=${VERSION_SHORT} \
|
|
|
|
-X tailscale.com/version.gitCommitStamp=${VERSION_GIT_HASH}" \
|
2022-12-13 17:40:41 +00:00
|
|
|
--base="${BASE}" \
|
|
|
|
--tags="${TAGS}" \
|
|
|
|
--repos="${REPOS}" \
|
|
|
|
--push="${PUSH}" \
|
2024-01-10 19:19:20 +00:00
|
|
|
--target="${PLATFORM}" \
|
2022-12-13 17:40:41 +00:00
|
|
|
/usr/local/bin/operator
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "unknown target: $TARGET"
|
|
|
|
exit 1
|
|
|
|
;;
|
2024-03-08 23:24:36 +00:00
|
|
|
esac
|