Skip to content

Commit

Permalink
SONAR-20383 Add retry mechanism for multi-architecture docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
carminevassallo committed Sep 27, 2023
1 parent a1a383e commit 67ae105
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ multi_arch_build_task:
- docker login --username $DOCKER_USERNAME --password $DOCKER_PASSWORD
setup_script:
- docker run -t --rm --privileged tonistiigi/binfmt --install all
- docker buildx create --name multibuilder
- docker buildx create --name multibuilder --driver docker-container
- docker buildx use multibuilder
- docker buildx inspect --bootstrap
build_script:
- echo "Build the ${STAGING_IMAGE_NAME}:${tag} image supporting two architectures, linux/amd64 and linux/arm64"
- docker buildx build --platform linux/amd64,linux/arm64 --tag "${STAGING_IMAGE_NAME}:${tag}" --push ${version}
- .cirrus/multi-arch-build.sh ${STAGING_IMAGE_NAME} ${tag} ${version}

private_scan_task:
env:
Expand Down
14 changes: 14 additions & 0 deletions .cirrus/multi-arch-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

export DOCKER_BUILDKIT=1
for i in $(seq 1 3); do
if docker buildx build --platform linux/amd64,linux/arm64 --tag "$1:$2" --push $3; then
echo "[Success]: Buildx, attempt ${i}"
break
fi
sleep 3
if [[ "${i}" == "3" ]]; then
echo "[Error]: Context Deadline Exceeded - Buildx"
exit 1
fi
done

0 comments on commit 67ae105

Please sign in to comment.