linkerd2/bin/docker-build-cli-bin

53 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
set -eu
if [ $# -ne 0 ]; then
echo "no arguments allowed for ${0##*/}, given: $*" >&2
exit 64
fi
bindir=$( cd "${BASH_SOURCE[0]%/*}" && pwd )
rootdir=$( cd "$bindir"/.. && pwd )
# shellcheck source=_docker.sh
. "$bindir"/_docker.sh
# shellcheck source=_tag.sh
. "$bindir"/_tag.sh
get_multiarch_argument() {
if [ -n "$DOCKER_MULTIARCH" ]; then
echo "--build-arg BUILD_STAGE=multi-arch"
fi
}
dockerfile=$rootdir/cli/Dockerfile-bin
tag=$(head_root_tag)
# shellcheck disable=SC2046
SUPPORTED_ARCHS=linux/amd64 docker_build cli-bin "$tag" "$dockerfile" \
--build-arg LINKERD_VERSION="$tag" \
$(get_multiarch_argument)
IMG=$(docker_repo cli-bin):$tag
ID=$(docker create "$IMG")
OS="darwin windows linux-amd64"
if [ -n "$DOCKER_MULTIARCH" ]; then
OS+=" linux-arm64 linux-arm"
fi
# copy the newly built linkerd cli binaries to the local system
for OS in $OS; do
DIR=$rootdir/target/cli/$OS
mkdir -p "$DIR"
if docker cp "$ID:/out/linkerd-${OS}" "$DIR/linkerd" ; then
echo "$DIR/linkerd"
else
docker rm "$ID" >/dev/null
exit 1
fi
done
docker rm "$ID" >/dev/null