2021-01-20 16:55:05 +00:00
|
|
|
#!/usr/bin/env sh
|
|
|
|
#
|
2024-07-30 15:12:43 +01:00
|
|
|
# This script builds Tailscale container images using
|
|
|
|
# github.com/tailscale/mkctr.
|
|
|
|
# By default the images will be tagged with the current version and git
|
|
|
|
# hash of this repository as produced by ./cmd/mkversion.
|
|
|
|
# This is the image build mechanim used to build the official Tailscale
|
|
|
|
# container images.
|
2021-01-20 16:55:05 +00:00
|
|
|
|
|
|
|
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"
|
2024-11-12 14:23:38 +00:00
|
|
|
# Set a few pre-defined OCI annotations. The source annotation is used by tools such as Renovate that scan the linked
|
|
|
|
# Github repo to find release notes for any new image tags. Note that for official Tailscale images the default
|
|
|
|
# annotations defined here will be overriden by release scripts that call this script.
|
|
|
|
# https://github.com/opencontainers/image-spec/blob/main/annotations.md#pre-defined-annotation-keys
|
|
|
|
DEFAULT_ANNOTATIONS="org.opencontainers.image.source=https://github.com/tailscale/tailscale/blob/main/build_docker.sh,org.opencontainers.image.vendor=Tailscale"
|
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
|
2024-11-12 14:23:38 +00:00
|
|
|
# OCI annotations that will be added to the image.
|
|
|
|
# https://github.com/opencontainers/image-spec/blob/main/annotations.md
|
|
|
|
ANNOTATIONS="${ANNOTATIONS:-${DEFAULT_ANNOTATIONS}}"
|
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-07-17 18:07:33 +01:00
|
|
|
--gotags="ts_kube,ts_package_container" \
|
2022-12-13 17:40:41 +00:00
|
|
|
--repos="${REPOS}" \
|
|
|
|
--push="${PUSH}" \
|
2024-01-10 19:19:20 +00:00
|
|
|
--target="${PLATFORM}" \
|
2024-11-12 14:23:38 +00:00
|
|
|
--annotations="${ANNOTATIONS}" \
|
2022-12-13 17:40:41 +00:00
|
|
|
/usr/local/bin/containerboot
|
|
|
|
;;
|
2024-11-29 15:32:18 +00:00
|
|
|
k8s-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}" \
|
2024-10-15 19:38:11 +01:00
|
|
|
--gotags="ts_kube,ts_package_container" \
|
2022-12-13 17:40:41 +00:00
|
|
|
--repos="${REPOS}" \
|
|
|
|
--push="${PUSH}" \
|
2024-01-10 19:19:20 +00:00
|
|
|
--target="${PLATFORM}" \
|
2024-11-12 14:23:38 +00:00
|
|
|
--annotations="${ANNOTATIONS}" \
|
2022-12-13 17:40:41 +00:00
|
|
|
/usr/local/bin/operator
|
|
|
|
;;
|
2024-04-30 20:18:23 +01:00
|
|
|
k8s-nameserver)
|
|
|
|
DEFAULT_REPOS="tailscale/k8s-nameserver"
|
|
|
|
REPOS="${REPOS:-${DEFAULT_REPOS}}"
|
|
|
|
go run github.com/tailscale/mkctr \
|
|
|
|
--gopaths="tailscale.com/cmd/k8s-nameserver:/usr/local/bin/k8s-nameserver" \
|
|
|
|
--ldflags=" \
|
|
|
|
-X tailscale.com/version.longStamp=${VERSION_LONG} \
|
|
|
|
-X tailscale.com/version.shortStamp=${VERSION_SHORT} \
|
|
|
|
-X tailscale.com/version.gitCommitStamp=${VERSION_GIT_HASH}" \
|
|
|
|
--base="${BASE}" \
|
|
|
|
--tags="${TAGS}" \
|
2024-10-15 19:38:11 +01:00
|
|
|
--gotags="ts_kube,ts_package_container" \
|
2024-04-30 20:18:23 +01:00
|
|
|
--repos="${REPOS}" \
|
|
|
|
--push="${PUSH}" \
|
|
|
|
--target="${PLATFORM}" \
|
2024-11-12 14:23:38 +00:00
|
|
|
--annotations="${ANNOTATIONS}" \
|
2024-04-30 20:18:23 +01:00
|
|
|
/usr/local/bin/k8s-nameserver
|
|
|
|
;;
|
2022-12-13 17:40:41 +00:00
|
|
|
*)
|
|
|
|
echo "unknown target: $TARGET"
|
|
|
|
exit 1
|
|
|
|
;;
|
2024-03-08 23:24:36 +00:00
|
|
|
esac
|