Skip to content

Commit

Permalink
Add manifest support for release images
Browse files Browse the repository at this point in the history
  • Loading branch information
mkumatag committed Aug 29, 2018
1 parent 7e27e08 commit a70044a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 22 deletions.
6 changes: 2 additions & 4 deletions build/Dockerfile.k8s-cloud-builder
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# To rebuild and publish this container run:
# gcloud builds submit --config update_build_container.yaml .

FROM ubuntu
FROM ubuntu:16.04

# Install packages
RUN apt-get -q update && apt-get install -qqy apt-transport-https \
Expand Down Expand Up @@ -47,7 +47,5 @@ RUN \
stable edge" && \
apt-get -y update

# As of 2018-04-10, leaving this pinned to 17.09 due to image pull issues
# with 17.12
ARG DOCKER_VERSION=17.09.0~ce-0~ubuntu
ARG DOCKER_VERSION=18.06.0~ce~3-0~ubuntu
RUN apt-get install -y docker-ce=${DOCKER_VERSION} unzip
42 changes: 24 additions & 18 deletions lib/releaselib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,7 @@ release::docker::release () {
local -a new_tags
local new_tag
local binary
local -A manifest_images

if [[ "$registry" == "$GCRIO_PATH_PROD" ]]; then
# Switch to the push alias if using the $GCRIO_PATH_PROD alias
Expand All @@ -924,28 +925,33 @@ release::docker::release () {
fi
binary=${BASH_REMATCH[1]}

# If amd64, tag both the legacy tag and -amd64 tag
if [[ "$arch" == "amd64" ]]; then
# binary may or may not already contain -amd64, so strip it first
new_tags=(\
"$push_registry/${binary/-amd64/}:$version"
"$push_registry/${binary/-amd64/}-amd64:$version"
)
else
new_tags=("$push_registry/$binary:$version")
fi
new_tag="$push_registry/${binary/-$arch/}"
new_tag_with_arch=("$new_tag-$arch:$version")
manifest_images["${new_tag}"]+=" $arch"

logrun docker load -qi $tarfile
for new_tag in ${new_tags[@]}; do
logrun docker tag $orig_tag $new_tag
logecho -n "Pushing $new_tag: "
# TODO: Use docker direct when fixed later
#logrun -r 5 -s docker push "$new_tag" || return 1
logrun -r 5 -s $GCLOUD docker -- push "$new_tag" || return 1
done
logrun docker rmi $orig_tag ${new_tags[@]} || true
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
logrun docker rmi $orig_tag ${new_tag_with_arch} || true

done
done

for image in "${!manifest_images[@]}"; do
local archs=$(echo "${manifest_images[$image]}" | sed -e 's/^[[:space:]]*//')
local manifest=$(echo $archs | sed -e "s~[^ ]*~$image\-&:$version~g")
# This command will push a manifest list: "${registry}/${image}-ARCH:${version}" that points to each architecture depending on which platform you're pulling from
logecho "Creating manifest image ${image}:${version}..."
logrun -r 5 -s docker manifest create --amend ${image}:${version} ${manifest} || return 1
for arch in ${archs}; do
logecho "Annotating ${image}-${arch}:${version} with --arch ${arch}..."
logrun -r 5 -s docker manifest annotate --arch ${arch} ${image}:${version} ${image}-${arch}:${version} || return 1
done
logecho "Pushing manifest image ${image}:${version}..."
logrun -r 5 -s docker manifest push ${image}:${version} || return 1
done

# Always reset back to $GCP_USER
Expand Down

0 comments on commit a70044a

Please sign in to comment.