images: Changes the image naming template

Changes the image naming template from:

$REGISTRY/$image-$arch:$TAG

to

$REGISTRY/$image:$TAG-$os_name-$arch

The previous naming template would generate a plethora of images (Ai * N images,
where Ai is the number of OS/architectures for the image i and N is the number
of images), while the new naming template will reduce the number of images to N.

The new template also includes the OS name, as we plan to integrate Windows
images into the manifest lists as well.
This commit is contained in:
Claudiu Belu 2019-04-17 15:13:51 +00:00
parent 25b7a13864
commit a4ceb143dd
3 changed files with 15 additions and 15 deletions

View File

@ -109,7 +109,7 @@ build() {
fi
fi
docker build --pull -t "${REGISTRY}/${image}-${arch}:${TAG}" .
docker build --pull -t "${REGISTRY}/${image}:${TAG}-${os_name}-${arch}" .
popd
done
@ -145,7 +145,7 @@ push() {
exit 1
fi
docker push "${REGISTRY}/${image}-${arch}:${TAG}"
docker push "${REGISTRY}/${image}:${TAG}-${os_name}-${arch}"
done
kube::util::ensure-gnu-sed
@ -154,8 +154,8 @@ push() {
export DOCKER_CLI_EXPERIMENTAL="enabled"
# reset manifest list; needed in case multiple images are being built / pushed.
manifest=()
# Make os_archs list into image manifest. Eg: 'linux/amd64 linux/ppc64le' to '${REGISTRY}/${image}-amd64:${TAG} ${REGISTRY}/${image}-ppc64le:${TAG}'
while IFS='' read -r line; do manifest+=("$line"); done < <(echo "$os_archs" | ${SED} "s~linux\/~~" | ${SED} -e "s~[^ ]*~$REGISTRY\/$image\-&:$TAG~g")
# Make os_archs list into image manifest. Eg: 'linux/amd64 linux/ppc64le' to '${REGISTRY}/${image}:${TAG}-linux-amd64 ${REGISTRY}/${image}:${TAG}-linux-ppc64le'
while IFS='' read -r line; do manifest+=("$line"); done < <(echo "$os_archs" | ${SED} "s~\/~-~" | ${SED} -e "s~[^ ]*~$REGISTRY\/$image:$TAG\-&~g")
docker manifest create --amend "${REGISTRY}/${image}:${TAG}" "${manifest[@]}"
for os_arch in ${os_archs}; do
if [[ $os_arch =~ .*/.* ]]; then
@ -165,7 +165,7 @@ push() {
echo "The BASEIMAGE file for the ${image} image is not properly formatted. Expected entries to start with 'os/arch', found '${os_arch}' instead."
exit 1
fi
docker manifest annotate --arch "${arch}" "${REGISTRY}/${image}:${TAG}" "${REGISTRY}/${image}-${arch}:${TAG}"
docker manifest annotate --arch "${arch}" "${REGISTRY}/${image}:${TAG}" "${REGISTRY}/${image}:${TAG}-${os_name}-${arch}"
done
docker manifest push --purge "${REGISTRY}/${image}:${TAG}"
}

View File

@ -1,5 +1,5 @@
linux/amd64=REGISTRY/agnhost-amd64:2.11
linux/arm=REGISTRY/agnhost-arm:2.11
linux/arm64=REGISTRY/agnhost-arm64:2.11
linux/ppc64le=REGISTRY/agnhost-ppc64le:2.11
linux/s390x=REGISTRY/agnhost-s390x:2.11
linux/amd64=REGISTRY/agnhost:2.11-linux-amd64
linux/arm=REGISTRY/agnhost:2.11-linux-arm
linux/arm64=REGISTRY/agnhost:2.11-linux-arm64
linux/ppc64le=REGISTRY/agnhost:2.11-linux-ppc64le
linux/s390x=REGISTRY/agnhost:2.11-linux-s390x

View File

@ -1,5 +1,5 @@
linux/amd64=REGISTRY/agnhost-amd64:2.11
linux/arm=REGISTRY/agnhost-arm:2.11
linux/arm64=REGISTRY/agnhost-arm64:2.11
linux/ppc64le=REGISTRY/agnhost-ppc64le:2.11
linux/s390x=REGISTRY/agnhost-s390x:2.11
linux/amd64=REGISTRY/agnhost:2.11-linux-amd64
linux/arm=REGISTRY/agnhost:2.11-linux-arm
linux/arm64=REGISTRY/agnhost:2.11-linux-arm64
linux/ppc64le=REGISTRY/agnhost:2.11-linux-ppc64le
linux/s390x=REGISTRY/agnhost:2.11-linux-s390x