Skip to content

Commit

Permalink
images: Use crane for pushing release images instead of docker
Browse files Browse the repository at this point in the history
Currently, we're loading the images into docker, retagging them, and
then push them onto the registry.

This workflow is incompatible with Windows images, as docker load does
not work for them, resulting in the following error:

cannot load windows image on linux

However, crane does not load the image, it just pushes it directly with
the given tag. This will allow us to push any Windows image we might have
(e.g.: Windows kube-proxy image).
  • Loading branch information
claudiubelu committed Mar 7, 2024
1 parent 5cdeee7 commit 1e14690
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions push-build.sh
Expand Up @@ -1348,6 +1348,16 @@ release::gcs::publish () {
fi
}

ensure_crane_exists () {
if ! command -v crane &> /dev/null; then
echo "Installing crane..."
CRANE_VERSION="v0.19.0"
curl -sL "https://github.com/google/go-containerregistry/releases/download/${CRANE_VERSION}/go-containerregistry_Linux_x86_64.tar.gz" > go-containerregistry.tar.gz
sudo tar -zxvf go-containerregistry.tar.gz -C /usr/local/bin/ crane
rm go-containerregistry.tar.gz
fi
}

###############################################################################
# Releases all docker images to a docker registry using the docker tarfiles.
#
Expand All @@ -1370,6 +1380,8 @@ release::docker::release () {

common::argc_validate 3

ensure_crane_exists

logecho "Send docker containers from release-images to $push_registry..."

mapfile -t arches < <(find "${release_images}" -maxdepth 1 -mindepth 1 -type d -exec basename {} \;)
Expand All @@ -1388,16 +1400,10 @@ release::docker::release () {
new_tag_with_arch=("$new_tag-$arch:$version")
manifest_images["${new_tag}"]+=" $arch"

logrun docker load -qi $tarfile
logrun docker tag $orig_tag ${new_tag_with_arch}
logecho -n "Pushing ${new_tag_with_arch}: "
# TODO: Use docker direct when fixed later
#logrun -r 5 -s docker push "${new_tag_with_arch}" || return 1
logrun -r 5 -s $GCLOUD docker -- push "${new_tag_with_arch}" || return 1
if [[ "${PURGE_IMAGES:-yes}" == "yes" ]] ; then
logrun docker rmi $orig_tag ${new_tag_with_arch} || true
fi

# We don't need to load the image when pushing it with crane.
# This will also allow us to push any Windows images we might have.
logrun -r 5 -s $GCLOUD crane push $tarfile "${new_tag_with_arch}" || return 1
done
done

Expand Down

0 comments on commit 1e14690

Please sign in to comment.