diff --git a/anago b/anago index fe4b0a3871d..a2c4682d562 100755 --- a/anago +++ b/anago @@ -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 diff --git a/build/Dockerfile.k8s-cloud-builder b/build/Dockerfile.k8s-cloud-builder index 2b7f68bf20a..34c38c690ea 100644 --- a/build/Dockerfile.k8s-cloud-builder +++ b/build/Dockerfile.k8s-cloud-builder @@ -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 \ @@ -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 diff --git a/lib/releaselib.sh b/lib/releaselib.sh index ab144c65aad..f53ea165640 100644 --- a/lib/releaselib.sh +++ b/lib/releaselib.sh @@ -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 @@ -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