Skip to content

Commit

Permalink
Merge pull request #45391 from david-mcmahon/docker_tag
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue

Only tag release containers if the name is different.

Fixes docker build issue found recently when trying to build v1.7.0-alpha.3.
ref #44981
  • Loading branch information
Kubernetes Submit Queue committed May 5, 2017
2 parents 3f6be95 + b82b3c0 commit 699606c
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions build/lib/release.sh
Expand Up @@ -287,18 +287,21 @@ function kube::release::create_docker_images_for_server() {
local docker_build_path="${binary_dir}/${binary_name}.dockerbuild"
local docker_file_path="${docker_build_path}/Dockerfile"
local binary_file_path="${binary_dir}/${binary_name}"
local docker_image_tag="${KUBE_DOCKER_REGISTRY:-gcr.io/google_containers}"

rm -rf ${docker_build_path}
mkdir -p ${docker_build_path}
ln ${binary_dir}/${binary_name} ${docker_build_path}/${binary_name}
printf " FROM ${base_image} \n ADD ${binary_name} /usr/local/bin/${binary_name}\n" > ${docker_file_path}

if [[ ${arch} == "amd64" ]]; then
# If we are building a amd64 docker image, preserve the original image name
local docker_image_tag="gcr.io/google_containers/${binary_name}:${docker_tag}"
# If we are building a amd64 docker image, preserve the original
# image name
docker_image_tag+="/${binary_name}:${docker_tag}"
else
# If we are building a docker image for another architecture, append the arch in the image tag
local docker_image_tag="gcr.io/google_containers/${binary_name}-${arch}:${docker_tag}"
# If we are building a docker image for another architecture,
# append the arch in the image tag
docker_image_tag+="/${binary_name}-${arch}:${docker_tag}"
fi

"${DOCKER[@]}" build --pull -q -t "${docker_image_tag}" ${docker_build_path} >/dev/null
Expand All @@ -307,13 +310,16 @@ function kube::release::create_docker_images_for_server() {

rm -rf ${docker_build_path}

# If we are building an official/alpha/beta release we want to keep docker images
# and tag them appropriately.
# If we are building an official/alpha/beta release we want to keep
# docker images and tag them appropriately.
if [[ -n "${KUBE_DOCKER_IMAGE_TAG-}" && -n "${KUBE_DOCKER_REGISTRY-}" ]]; then
local release_docker_image_tag="${KUBE_DOCKER_REGISTRY}/${binary_name}-${arch}:${KUBE_DOCKER_IMAGE_TAG}"
kube::log::status "Tagging docker image ${docker_image_tag} as ${release_docker_image_tag}"
"${DOCKER[@]}" rmi "${release_docker_image_tag}" 2>/dev/null || true
"${DOCKER[@]}" tag "${docker_image_tag}" "${release_docker_image_tag}" 2>/dev/null
# Only rmi and tag if name is different
if [[ $docker_image_tag != $release_docker_image_tag ]]; then
kube::log::status "Tagging docker image ${docker_image_tag} as ${release_docker_image_tag}"
"${DOCKER[@]}" rmi "${release_docker_image_tag}" 2>/dev/null || true
"${DOCKER[@]}" tag "${docker_image_tag}" "${release_docker_image_tag}" 2>/dev/null
fi
fi

kube::log::status "Deleting docker image ${docker_image_tag}"
Expand Down

0 comments on commit 699606c

Please sign in to comment.