This is an automated email from the ASF dual-hosted git repository.

aw pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/yetus.git


The following commit(s) were added to refs/heads/main by this push:
     new ec90dd7  YETUS-1147. disable multi-platform on buildx docker instance 
(#243)
ec90dd7 is described below

commit ec90dd76795b6e3ef8c43a55feecc787469d1ac6
Author: Allen Wittenauer <[email protected]>
AuthorDate: Sun Nov 28 10:14:16 2021 -0800

    YETUS-1147. disable multi-platform on buildx docker instance (#243)
---
 hooks/build | 35 +++++++++++++++++++++--------------
 1 file changed, 21 insertions(+), 14 deletions(-)

diff --git a/hooks/build b/hooks/build
index fdfb22e..0579a2a 100755
--- a/hooks/build
+++ b/hooks/build
@@ -60,8 +60,6 @@ opencontainerslabels() {
     done
   fi
 
-
-
  for label in \
     "org.opencontainers.image.created=$(iso8601date)" \
     "org.opencontainers.image.source=${GIT_URL}" \
@@ -102,24 +100,32 @@ if [[ -z "${DOCKER_REPO}" ]]; then
   export DOCKER_REPO
 fi
 
-KNOWN_PLATFORMS=$(docker buildx inspect --bootstrap)
+BUILDERINSTANCE=$(docker buildx inspect --bootstrap | grep Driver)
+PLATARRAY=()
 
-if [[ ${KNOWN_PLATFORMS} =~ linux/amd64 ]]; then
-  PLATFORMS+=(linux/amd64)
-fi
+if [[ "${BUILDERINSTANCE}" =~ docker-container ]]; then
+  KNOWN_PLATFORMS=$(docker buildx inspect --bootstrap | grep Platforms)
 
-if [[ ${KNOWN_PLATFORMS} =~ linux/arm64 ]]; then
-  PLATFORMS+=(linux/arm64)
-fi
+  if [[ ${KNOWN_PLATFORMS} =~ linux/amd64 ]]; then
+    PLATFORMS+=(linux/amd64)
+  fi
 
-PLATSTRING=${PLATFORMS[*]}
-PLATSTRING=${PLATSTRING/ /,}
-echo "Building for ${PLATSTRING}"
+  if [[ ${KNOWN_PLATFORMS} =~ linux/arm64 ]]; then
+    PLATFORMS+=(linux/arm64)
+  fi
+
+  PLATSTRING=${PLATFORMS[*]}
+  PLATSTRING=${PLATSTRING/ /,}
+  echo "Building for ${PLATSTRING}"
+
+  PLATARRAY=(--platform "${PLATSTRING}")
+fi
 
 opencontainerslabels "base"
 
 # Build the -base image
-docker buildx build --platform "${PLATSTRING}" \
+docker buildx build \
+  "${PLATARRAY[@]}" \
   "${LABELS[@]}" \
   --tag "${DOCKER_REPO}-base:${DOCKER_TAG}" \
   --push \
@@ -128,7 +134,8 @@ docker buildx build --platform "${PLATSTRING}" \
 opencontainerslabels "full"
 
 # Build the full image using base above
-docker buildx build --platform "${PLATSTRING}" \
+docker buildx build \
+  "${PLATARRAY[@]}" \
   --label 
"org.opencontainers.image.base.name=${DOCKER_REPO}-base:${DOCKER_TAG}" \
   "${LABELS[@]}" \
   --tag "${DOCKER_REPO}:${DOCKER_TAG}" \

Reply via email to