add multiarch test images to local registry (#3745)

populate-registry.sh currently creates variations of TinyCore Linux.
In order to allow testing of multiarch import capabilities in CDI in the
future, it's required to allow populate-registry to build the container
image for multiple architectures as well as construct an image index.

This commit introduces the ability to do this and by default builds only
tinycore.qcow2 for the amd64, arm64 and s390x architectures.

Signed-off-by: Adi Aloni <aaloni@redhat.com>
This commit is contained in:
Adi Aloni 2025-05-29 04:06:06 +03:00 committed by GitHub
parent 654a673604
commit 28c5301437
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5,6 +5,9 @@
# Container images are built with buildah
CONTAINER_DISK_IMAGE=${CONTAINER_DISK_IMAGE:-quay.io/kubevirt/container-disk-v1alpha}
ARCHITECTURES="${ARCHITECTURES:-amd64,arm64,s390x}"
: "${MULTIARCH_IMAGES:=tinycoreqcow2}"
MULTIARCH_IMAGES=($MULTIARCH_IMAGES)
#images args
IMAGES_SRC=$1 #path to files to be encapsulated in docker image
@ -44,6 +47,15 @@ function imageList {
echo curl -k -X GET https://$registry/v2/_catalog
}
in_array() {
local item match="$1"
shift
for item; do
[[ "$item" == "$match" ]] && return 0
done
return 1
}
#Convert all images to docker build consumable format
DIR="-dir"
DOCKERFILE="Dockerfile"
@ -108,11 +120,18 @@ function pushImages {
FILE=$(ls | grep -v $DOCKERFILE)
IMAGENAME=${FILE//.}
echo "building image "$IMAGENAME
buildah bud -t $IMAGENAME":latest" $images"/"$IMAGEDIR"/"
if in_array "$IMAGENAME" "${MULTIARCH_IMAGES[@]}"; then
buildah bud --platform $ARCHITECTURES --manifest $IMAGENAME":latest" $images"/"$IMAGEDIR"/"
error $?
echo "pushing image "$IMAGENAME" to registry-service: "$registry
buildah manifest push --all $registry_tls $IMAGENAME":latest" "docker://"$registry"/"$IMAGENAME
else
buildah bud -t $IMAGENAME":latest" $images"/"$IMAGEDIR"/"
error $?
echo "pushing image "$IMAGENAME" to registry-service: "$registry
buildah push $registry_tls $IMAGENAME":latest" "docker://"$registry"/"$IMAGENAME
fi
error $?
echo "pushing image "$IMAGENAME" to registry-service: "$registry
buildah push $registry_tls $IMAGENAME":latest" "docker://"$registry"/"$IMAGENAME
error $?
cd ../
done
}