#!/bin/bash set -e # Stop on error if [ $# -ne 2 ]; then echo "Usage: $0 " 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}"