50 lines
1.9 KiB
Bash
Executable File
50 lines
1.9 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
|
||
|
||
# 🛑 Remove the old multi-architecture manifest to prevent duplicates
|
||
echo "🗑️ Removing existing manifest list for ${IMAGE_MULTI} (if exists)..."
|
||
docker manifest rm ${IMAGE_MULTI} || true # Ignore errors if it doesn’t exist
|
||
|
||
echo "🗑️ Removing existing manifest list for ${IMAGE_LATEST} (if exists)..."
|
||
docker manifest rm ${IMAGE_LATEST} || true # Ignore errors if it doesn’t exist
|
||
|
||
# 🏗️ Create the new multi-architecture manifest
|
||
echo "📜 Creating new 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 "📜 Creating new 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}"
|
||
|