From 7f79ffb4092be1235d83a85657351145d3542405 Mon Sep 17 00:00:00 2001 From: Angus Lees Date: Tue, 19 Jan 2021 11:52:15 +1100 Subject: [PATCH 1/2] Generate and push multi-arch docker manifest list Change amd64 docker image to use a `-amd64` suffix, consistent with other architectures. Introduce a multiarch docker manifest list with the original (no-arch) docker tag. Fixes #10380 --- ...erfile-release => Dockerfile-release.amd64 | 0 scripts/build-docker | 9 ++---- scripts/release | 32 +++++++++++++------ 3 files changed, 24 insertions(+), 17 deletions(-) rename Dockerfile-release => Dockerfile-release.amd64 (100%) diff --git a/Dockerfile-release b/Dockerfile-release.amd64 similarity index 100% rename from Dockerfile-release rename to Dockerfile-release.amd64 diff --git a/scripts/build-docker b/scripts/build-docker index e32aedd9c..bc5fd7a10 100755 --- a/scripts/build-docker +++ b/scripts/build-docker @@ -7,9 +7,9 @@ if [ "$#" -ne 1 ]; then exit 1 fi -VERSION=${1} ARCH=$(go env GOARCH) -DOCKERFILE="Dockerfile-release" +VERSION="${1}-${ARCH}" +DOCKERFILE="Dockerfile-release.${ARCH}" if [ -z "${BINARYDIR}" ]; then RELEASE="etcd-${1}"-$(go env GOOS)-$(go env GOARCH) @@ -23,11 +23,6 @@ if [ -z "${BINARYDIR}" ]; then tar -zvxf "${TARFILE}" fi -if [ "${ARCH}" != "amd64" ]; then - DOCKERFILE+=".${ARCH}" - VERSION+="-${ARCH}" -fi - BINARYDIR=${BINARYDIR:-.} BUILDDIR=${BUILDDIR:-.} diff --git a/scripts/release b/scripts/release index 35084c810..c36e0f48f 100755 --- a/scripts/release +++ b/scripts/release @@ -35,6 +35,9 @@ main() { BRANCH=${BRANCH:-"release-${MINOR_VERSION}"} REPOSITORY=${REPOSITORY:-"https://github.com/etcd-io/etcd"} + # Required to enable 'docker manifest ...' + export DOCKER_CLI_EXPERIMENTAL=enabled + if ! command -v docker >/dev/null; then echo "cannot find docker" exit 1 @@ -191,20 +194,29 @@ main() { done gcloud docker -- login -u _json_key -p "$(cat /etc/gcp-key-etcd-development.json)" https://gcr.io - echo "Pushing container images to quay.io ${RELEASE_VERSION}" - docker push "quay.io/coreos/etcd:${RELEASE_VERSION}" + # NB: `docker manifest create` insists on at least one manifest. + # We overwrite it later with --amend anyway. + docker manifest create "quay.io/coreos/etcd:${RELEASE_VERSION}" "quay.io/coreos/etcd:${RELEASE_VERSION}-amd64" + docker manifest create "gcr.io/etcd-development/etcd:${RELEASE_VERSION}" "gcr.io/etcd-development/etcd:${RELEASE_VERSION}-amd64" - echo "Pushing container images to gcr.io ${RELEASE_VERSION}" - gcloud docker -- push "gcr.io/etcd-development/etcd:${RELEASE_VERSION}" + for TARGET_ARCH in "amd64" "arm64" "ppc64le" "s390x"; do + echo "Pushing container images to quay.io ${RELEASE_VERSION}-${TARGET_ARCH}" + docker push "quay.io/coreos/etcd:${RELEASE_VERSION}-${TARGET_ARCH}" + docker manifest create --amend "quay.io/coreos/etcd:${RELEASE_VERSION}" "quay.io/coreos/etcd:${RELEASE_VERSION}-${TARGET_ARCH}" + docker manifest annotate "quay.io/coreos/etcd:${RELEASE_VERSION}" "quay.io/coreos/etcd:${RELEASE_VERSION}-${TARGET_ARCH}" --arch "${TARGET_ARCH}" - for TARGET_ARCH in "-arm64" "-ppc64le" "-s390x"; do - echo "Pushing container images to quay.io ${RELEASE_VERSION}${TARGET_ARCH}" - docker push "quay.io/coreos/etcd:${RELEASE_VERSION}${TARGET_ARCH}" - - echo "Pushing container images to gcr.io ${RELEASE_VERSION}${TARGET_ARCH}" - gcloud docker -- push "gcr.io/etcd-development/etcd:${RELEASE_VERSION}${TARGET_ARCH}" + echo "Pushing container images to gcr.io ${RELEASE_VERSION}-${TARGET_ARCH}" + gcloud docker -- push "gcr.io/etcd-development/etcd:${RELEASE_VERSION}-${TARGET_ARCH}" + docker manifest create --amend "gcr.io/etcd-development/etcd:${RELEASE_VERSION}" "gcr.io/etcd-development/etcd:${RELEASE_VERSION}-${TARGET_ARCH}" + docker manifest annotate "gcr.io/etcd-development/etcd:${RELEASE_VERSION}" "gcr.io/etcd-development/etcd:${RELEASE_VERSION}-${TARGET_ARCH}" --arch "${TARGET_ARCH}" done + echo "Pushing container manifest list to quay.io ${RELEASE_VERSION}" + docker manifest push "quay.io/coreos/etcd:${RELEASE_VERSION}" + + echo "Pushing container manifest list to gcr.io ${RELEASE_VERSION}" + gcloud docker -- manifest push "gcr.io/etcd-development/etcd:${RELEASE_VERSION}" + echo "Setting permissions using gsutil..." gsutil -m acl ch -u allUsers:R -r gs://artifacts.etcd-development.appspot.com fi From 2529fee958ee8101111e39ec18a7373104962936 Mon Sep 17 00:00:00 2001 From: Angus Lees Date: Tue, 19 Jan 2021 12:10:29 +1100 Subject: [PATCH 2/2] Use /build instead of deprecated /build.sh --- scripts/build-binary | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build-binary b/scripts/build-binary index 5bc31cc49..bfd80408b 100755 --- a/scripts/build-binary +++ b/scripts/build-binary @@ -84,7 +84,7 @@ function main { export GOARCH=${TARGET_ARCH} pushd etcd >/dev/null - GO_LDFLAGS="-s" ./build + GO_LDFLAGS="-s" ./build.sh popd >/dev/null TARGET="etcd-${VER}-${GOOS}-${GOARCH}"