From eb64ed9dc9994f76144ec6e5a4b88a96124b2290 Mon Sep 17 00:00:00 2001 From: adriancole Date: Thu, 17 Dec 2020 15:27:55 +0800 Subject: [PATCH] fix arch --- build-bin/build | 1 + build-bin/deploy | 1 + build-bin/docker/docker_push | 47 ++++++++++++++++++++++++------------ 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/build-bin/build b/build-bin/build index ecd222e..f33e1af 100755 --- a/build-bin/build +++ b/build-bin/build @@ -8,4 +8,5 @@ if [ "${version}" != "master" ]; then fi export DOCKER_FILE=Dockerfile +export DOCKER_ARCHS=amd64 build-bin/docker/docker_build openzipkin/java:test ${version} diff --git a/build-bin/deploy b/build-bin/deploy index e68cffa..82921a8 100755 --- a/build-bin/deploy +++ b/build-bin/deploy @@ -11,6 +11,7 @@ fi # Base layers are not pushed to Docker Hub (docker.io) export DOCKER_RELEASE_REPOS=ghcr.io export DOCKER_FILE=Dockerfile +export DOCKER_ARCHS=amd64 # Don't make latest tag DOCKER_TAGS=${version} build-bin/docker/docker_push openzipkin/java ${version} diff --git a/build-bin/docker/docker_push b/build-bin/docker/docker_push index e4a3223..8d6266b 100755 --- a/build-bin/docker/docker_push +++ b/build-bin/docker/docker_push @@ -69,6 +69,7 @@ docker_archs=${DOCKER_ARCHS:-amd64 arm64} echo "Will build the following architectures: ${docker_archs}" docker_tag0="$(echo ${docker_tags} | awk '{print $1;}')" +docker_arch0="$(echo ${docker_archs} | awk '{print $1;}')" arch_tags="" for docker_arch in ${docker_archs}; do arch_tag=${docker_image}:${docker_tag0}-${docker_arch} @@ -79,24 +80,38 @@ done echo "Will push the following tags:\n${tags}" -for tag in $(echo ${tags} | xargs); do - manifest_tags="" - for arch_tag in ${arch_tags}; do - docker_arch=$(echo ${arch_tag} | sed 's/.*-//g') - manifest_tag=${tag}-${docker_arch} - docker tag ${arch_tag} ${manifest_tag} - echo "Pushing tag ${manifest_tag}..." - docker push ${manifest_tag} - manifest_tags="${manifest_tags} ${manifest_tag}" +if [ "${docker_arch0}" = "${docker_archs}" ]; then + # single architecture + arch_tag=${docker_image}:${docker_tag0}-${docker_arch0} + + for tag in $(echo ${tags} | xargs); do + docker tag ${arch_tag} ${tag} + echo "Pushing tag ${tag}..." + docker push ${tag} done - docker manifest create ${tag} ${manifest_tags} +else + # multi-architecture: make a manifest + for tag in $(echo ${tags} | xargs); do + manifest_tags="" + for arch_tag in ${arch_tags}; do + docker_arch=$(echo ${arch_tag} | sed 's/.*-//g') + manifest_tag=${tag}-${docker_arch} + docker tag ${arch_tag} ${manifest_tag} + echo "Pushing tag ${manifest_tag}..." + docker push ${manifest_tag} + manifest_tags="${manifest_tags} ${manifest_tag}" + done + + docker manifest create ${tag} ${manifest_tags} - for manifest_tag in ${manifest_tags}; do - docker_arch=$(echo ${manifest_tag} | sed 's/.*-//g') - docker manifest annotate ${tag} ${manifest_tag} --os linux --arch ${docker_arch} + for manifest_tag in ${manifest_tags}; do + docker_arch=$(echo ${manifest_tag} | sed 's/.*-//g') + docker manifest annotate ${tag} ${manifest_tag} --os linux --arch ${docker_arch} + done + + echo "Pushing manifest ${manifest_tag}..." + docker manifest push -p ${tag} done +fi - echo "Pushing manifest ${manifest_tag}..." - docker manifest push -p ${tag} -done