Skip to content

Commit

Permalink
Merge pull request #516 from mkumatag/manifest
Browse files Browse the repository at this point in the history
Add manifest support for release images
  • Loading branch information
k8s-ci-robot authored Sep 4, 2018
2 parents 7e27e08 + 59dc8ed commit ff17b75
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 22 deletions.
21 changes: 21 additions & 0 deletions anago
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,27 @@ check_prerequisites () {

security_layer::auth_check 2 || return 1

logecho -n "Checking Docker version: "
docker_version=$(docker version --format '{{.Client.Version}}' | cut -d"-" -f1)
if [[ ${docker_version} != 18.06.0 && ${docker_version} < 18.06.0 ]]; then
logecho "Minimum docker version 18.06.0 is required for " \
"creating and pushing manifest images[found: ${docker_version}]"
return 1
fi
logecho -r "$OK"

# TODO: Remove this section once docker manifest command promoted
# from Experimental
logecho -n "Checking Docker CLI Experimental status: "
cli_experimental=$(docker version --format '{{.Client.Experimental}}' | cut -d"-" -f1)
if [[ "${cli_experimental}" == "false" ]]; then
logecho "Docker Client Experimental flag is false, should be enabled to " \
"push the manifest images"
logecho "More info: https://docs.docker.com/edge/engine/reference/commandline/manifest_create/"
return 1
fi
logecho -r "$OK"

if ! ((FLAGS_gcb)); then
ensure_gcp_users || return 1
fi
Expand Down
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 ff17b75

Please sign in to comment.