42 lines
1.5 KiB
Bash
Executable File
42 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -e # Stop on error
|
|
|
|
if [ $# -ne 2 ]; then
|
|
echo "Usage: $0 <image-name> <commit-id>"
|
|
echo "Example: $0 base-debian 0e85448"
|
|
exit 1
|
|
fi
|
|
|
|
IMAGE_NAME=$1
|
|
COMMIT_ID=$2
|
|
REPO="registry.tomastm.com"
|
|
|
|
# Define image tags
|
|
IMAGE_AMD64="${REPO}/${IMAGE_NAME}:${COMMIT_ID}-amd64"
|
|
IMAGE_ARM64="${REPO}/${IMAGE_NAME}:${COMMIT_ID}-arm64"
|
|
IMAGE_MULTI="${REPO}/${IMAGE_NAME}:${COMMIT_ID}"
|
|
IMAGE_LATEST="${REPO}/${IMAGE_NAME}:latest"
|
|
|
|
# Check if both architectures exist in the registry
|
|
echo "🔎 Checking if both architectures exist..."
|
|
if ! docker manifest inspect ${IMAGE_AMD64} &>/dev/null || ! docker manifest inspect ${IMAGE_ARM64} &>/dev/null; then
|
|
echo "❌ Error: One or both architectures are missing in the registry."
|
|
echo "Ensure both ${IMAGE_AMD64} and ${IMAGE_ARM64} are pushed before running this script."
|
|
exit 1
|
|
fi
|
|
|
|
# Create the multi-architecture manifest for the commit ID
|
|
echo "📜 Creating multi-architecture manifest for ${COMMIT_ID}..."
|
|
docker manifest create ${IMAGE_MULTI} ${IMAGE_AMD64} ${IMAGE_ARM64}
|
|
|
|
# Push the multi-arch manifest for the commit ID
|
|
docker manifest push ${IMAGE_MULTI}
|
|
echo "✅ Successfully pushed multi-arch manifest: ${IMAGE_MULTI}"
|
|
|
|
# Create and push the latest multi-architecture manifest
|
|
echo "🔄 Updating latest multi-architecture manifest..."
|
|
docker manifest create ${IMAGE_LATEST} ${IMAGE_AMD64} ${IMAGE_ARM64}
|
|
docker manifest push ${IMAGE_LATEST}
|
|
echo "✅ Successfully updated latest manifest: ${IMAGE_LATEST}"
|