From e9d7ab64f50a4c5555eee2bfccab6d93b3ba0c41 Mon Sep 17 00:00:00 2001 From: ViViDboarder Date: Mon, 10 Feb 2020 18:46:44 -0800 Subject: [PATCH] Update mutli-arch builds on docker hub --- hooks/post_push | 43 +++++++++++++++++++++++++++++++++++++------ hooks/pre_build | 35 ----------------------------------- 2 files changed, 37 insertions(+), 41 deletions(-) diff --git a/hooks/post_push b/hooks/post_push index 45931a5..4a473f4 100755 --- a/hooks/post_push +++ b/hooks/post_push @@ -4,10 +4,41 @@ # "docker manifest" command isn't available yet on Docker Hub. TAG_ROOT=${DOCKER_TAG%-*} -TARGET_ARCH=${DOCKER_TAG##*-} -if [[ "$TARGET_ARCH" == "latest" ]]; then - echo "Building a non-arch tag. Skip manifest push" - exit 0 +TARGET_ARCH="" +case "$DOCKER_TAG" in + *amd64) + TARGET_ARCH="amd64" + ;; + *arm32v5) + TARGET_ARCH="arm32v5" + ;; + *arm32v6) + TARGET_ARCH="arm32v6" + ;; + *arm32v7) + TARGET_ARCH="arm32v7" + ;; + *arm64v8) + TARGET_ARCH="arm64v8" + ;; + *i386) + TARGET_ARCH="i386" + ;; + *ppc64le) + TARGET_ARCH="ppc64le" + ;; + *s390x) + TARGET_ARCH="s390x" + ;; + *) + echo "Unknown target arch, skip manifest push" + exit 0 + ;; +esac + +# If the tag is essentially only the arch, we use latest +if [[ "$TAG_ROOT" == "$TARGET_ARCH" ]]; then + TAG_ROOT="latest" fi curl -Lo manifest-tool https://github.com/estesp/manifest-tool/releases/download/v0.9.0/manifest-tool-linux-amd64 @@ -15,5 +46,5 @@ chmod +x manifest-tool ./manifest-tool push from-args \ --platforms "linux/$TARGET_ARCH" \ - --template "$DOCKER_REPO:${TAG_ROOT}-ARCH" \ - --target "$DOCKER_REPO:${TAG_ROOT}" + --template "$DOCKER_REPO:$DOCKER_TAG" \ + --target "$DOCKER_REPO:$TAG_ROOT" diff --git a/hooks/pre_build b/hooks/pre_build index cc124f1..e76a49a 100755 --- a/hooks/pre_build +++ b/hooks/pre_build @@ -1,39 +1,4 @@ #!/bin/bash set -ex -REPO="" -case "$DOCKER_TAG" in - *amd64) - REPO="library" - ;; - *arm32v5) - REPO="arm32v5" - ;; - *arm32v6) - REPO="arm32v6" - ;; - *arm32v7) - REPO="arm32v7" - ;; - *arm64v8) - REPO="arm64v8" - ;; - *i386) - REPO="i386" - ;; - *ppc64le) - REPO="ppc64le" - ;; - *s390x) - REPO="s390x" - ;; - *) - REPO="library" - ;; -esac - - -[ "${REPO}" != "library" ] && \ - { echo 'qemu-user-static: Registration not required for current arch'; exit 0; } - docker run --rm --privileged multiarch/qemu-user-static:register --reset