build_docker.sh: use github.com/tailscale/mkctr instead of docker

Signed-off-by: Maisem Ali <maisem@tailscale.com>
(cherry picked from commit 9feb483ad3)
This commit is contained in:
Maisem Ali 2021-11-21 20:52:19 -08:00
parent aee2387d6e
commit c005f67314
5 changed files with 23 additions and 10 deletions

View File

@ -56,6 +56,5 @@ RUN GOARCH=$TARGETARCH go install -tags=xversion -ldflags="\
-X tailscale.com/version.GitCommit=$VERSION_GIT_HASH" \ -X tailscale.com/version.GitCommit=$VERSION_GIT_HASH" \
-v ./cmd/tailscale ./cmd/tailscaled -v ./cmd/tailscale ./cmd/tailscaled
FROM alpine:3.14 FROM ghcr.io/tailscale/alpine-base:3.14
RUN apk add --no-cache ca-certificates iptables iproute2 ip6tables
COPY --from=build-env /go/bin/* /usr/local/bin/ COPY --from=build-env /go/bin/* /usr/local/bin/

6
Dockerfile.base Normal file
View File

@ -0,0 +1,6 @@
# Copyright (c) 2021 Tailscale Inc & AUTHORS All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
FROM alpine:3.14
RUN apk add --no-cache ca-certificates iptables iproute2 ip6tables

View File

@ -23,9 +23,8 @@ build386:
buildlinuxarm: buildlinuxarm:
GOOS=linux GOARCH=arm go install tailscale.com/cmd/tailscale tailscale.com/cmd/tailscaled GOOS=linux GOARCH=arm go install tailscale.com/cmd/tailscale tailscale.com/cmd/tailscaled
buildmultiarchimage: buildmultiarchimage:
docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t ${IMAGE_REPO}:latest --push -f Dockerfile . ./build_docker.sh
check: staticcheck vet depaware buildwindows build386 buildlinuxarm check: staticcheck vet depaware buildwindows build386 buildlinuxarm

View File

@ -30,12 +30,14 @@ else
fi fi
long_suffix="$change_suffix-t$short_hash" long_suffix="$change_suffix-t$short_hash"
SHORT="$major.$minor.$patch" MINOR="$major.$minor"
SHORT="$MINOR.$patch"
LONG="${SHORT}$long_suffix" LONG="${SHORT}$long_suffix"
GIT_HASH="$git_hash" GIT_HASH="$git_hash"
if [ "$1" = "shellvars" ]; then if [ "$1" = "shellvars" ]; then
cat <<EOF cat <<EOF
VERSION_MINOR="$MINOR"
VERSION_SHORT="$SHORT" VERSION_SHORT="$SHORT"
VERSION_LONG="$LONG" VERSION_LONG="$LONG"
VERSION_GIT_HASH="$GIT_HASH" VERSION_GIT_HASH="$GIT_HASH"

View File

@ -21,8 +21,15 @@ set -eu
eval $(./build_dist.sh shellvars) eval $(./build_dist.sh shellvars)
docker build \ go run github.com/tailscale/mkctr@latest \
--build-arg VERSION_LONG=$VERSION_LONG \ --base="ghcr.io/tailscale/alpine-base:3.14" \
--build-arg VERSION_SHORT=$VERSION_SHORT \ --gopaths="\
--build-arg VERSION_GIT_HASH=$VERSION_GIT_HASH \ tailscale.com/cmd/tailscale:/usr/local/bin/tailscale, \
-t tailscale:$VERSION_SHORT -t tailscale:latest . tailscale.com/cmd/tailscaled:/usr/local/bin/tailscaled" \
--ldflags="\
-X tailscale.com/version.Long=${VERSION_LONG} \
-X tailscale.com/version.Short=${VERSION_SHORT} \
-X tailscale.com/version.GitCommit=${VERSION_GIT_HASH}" \
--tags="${VERSION_SHORT},${VERSION_MINOR}" \
--repos="tailscale/tailscale,ghcr.io/tailscale/tailscale" \
--push