Build multi-architecture container releases
All checks were successful
Build and Publish Container / publish (push) Successful in 8m38s
All checks were successful
Build and Publish Container / publish (push) Successful in 8m38s
This commit is contained in:
@@ -27,32 +27,36 @@ jobs:
|
||||
|
||||
- name: Build and push image
|
||||
run: |
|
||||
push_image() {
|
||||
local image="$1"
|
||||
docker run --privileged --rm tonistiigi/binfmt --install arm64
|
||||
BUILDER="stun-nat-${GITHUB_RUN_ID}"
|
||||
docker buildx create --driver docker-container --name "$BUILDER" --use
|
||||
trap 'docker buildx rm "$BUILDER"' EXIT
|
||||
docker buildx inspect --bootstrap
|
||||
|
||||
build_and_push() {
|
||||
local attempt=1
|
||||
until docker push "$image"; do
|
||||
until docker buildx build --platform linux/amd64,linux/arm64 --pull --push "${TAGS[@]}" .; do
|
||||
if [ "$attempt" -ge 3 ]; then
|
||||
echo "Failed to push ${image} after ${attempt} attempts"
|
||||
echo "Failed to build and publish multi-architecture image after ${attempt} attempts"
|
||||
return 1
|
||||
fi
|
||||
attempt=$((attempt + 1))
|
||||
echo "Push failed; retrying ${image} (${attempt}/3) in 10 seconds"
|
||||
echo "Build or push failed; retrying (${attempt}/3) in 10 seconds"
|
||||
sleep 10
|
||||
done
|
||||
}
|
||||
|
||||
SHA_TAG="sha-${GITHUB_SHA}"
|
||||
docker build --pull --tag "${IMAGE}:${SHA_TAG}" .
|
||||
push_image "${IMAGE}:${SHA_TAG}"
|
||||
TAGS=(--tag "${IMAGE}:${SHA_TAG}")
|
||||
|
||||
if [ "$GITHUB_REF" = "refs/heads/main" ]; then
|
||||
docker tag "${IMAGE}:${SHA_TAG}" "${IMAGE}:latest"
|
||||
push_image "${IMAGE}:latest"
|
||||
TAGS+=(--tag "${IMAGE}:latest")
|
||||
fi
|
||||
|
||||
case "$GITHUB_REF" in
|
||||
refs/tags/v*)
|
||||
docker tag "${IMAGE}:${SHA_TAG}" "${IMAGE}:${GITHUB_REF_NAME}"
|
||||
push_image "${IMAGE}:${GITHUB_REF_NAME}"
|
||||
TAGS+=(--tag "${IMAGE}:${GITHUB_REF_NAME}")
|
||||
;;
|
||||
esac
|
||||
|
||||
build_and_push
|
||||
|
||||
Reference in New Issue
Block a user