Created
October 23, 2021 21:21
-
-
Save paralin/f29a67230b1f5ad73d72bafb2e4a54d7 to your computer and use it in GitHub Desktop.
Create a multi-arch docker image from arch tags
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eo pipefail | |
pull_image() { | |
if ! docker inspect $1 ; then | |
docker pull $1 | |
fi | |
docker inspect $1 | |
} | |
IMAGE=$1 | |
if [ -z "$IMAGE" ]; then | |
echo "set image as argument" | |
exit 1 | |
fi | |
ARCH_TAGS=(\ | |
arm \ | |
arm64 \ | |
amd64 \ | |
) | |
ARCH_IMAGES=("${ARCH_TAGS[@]/#/${IMAGE}:}") | |
echo "Inspecting / fetching images for ${IMAGE}..." | |
for aarch in "${ARCH_TAGS[@]}"; do | |
echo "Getting tag ${aarch}..." | |
pull_image ${IMAGE}:${aarch} | |
done | |
TARGET=${IMAGE}:latest | |
echo "Creating manifest ${TARGET}..." | |
docker manifest create --amend $TARGET ${ARCH_IMAGES[@]} | |
docker manifest push --purge ${TARGET} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment