mirror of https://github.com/k3s-io/k3s
Merge pull request #45391 from david-mcmahon/docker_tag
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 #44981pull/6/head
commit
699606cbfa
|
@ -287,6 +287,7 @@ function kube::release::create_docker_images_for_server() {
|
||||||
local docker_build_path="${binary_dir}/${binary_name}.dockerbuild"
|
local docker_build_path="${binary_dir}/${binary_name}.dockerbuild"
|
||||||
local docker_file_path="${docker_build_path}/Dockerfile"
|
local docker_file_path="${docker_build_path}/Dockerfile"
|
||||||
local binary_file_path="${binary_dir}/${binary_name}"
|
local binary_file_path="${binary_dir}/${binary_name}"
|
||||||
|
local docker_image_tag="${KUBE_DOCKER_REGISTRY:-gcr.io/google_containers}"
|
||||||
|
|
||||||
rm -rf ${docker_build_path}
|
rm -rf ${docker_build_path}
|
||||||
mkdir -p ${docker_build_path}
|
mkdir -p ${docker_build_path}
|
||||||
|
@ -294,11 +295,13 @@ function kube::release::create_docker_images_for_server() {
|
||||||
printf " FROM ${base_image} \n ADD ${binary_name} /usr/local/bin/${binary_name}\n" > ${docker_file_path}
|
printf " FROM ${base_image} \n ADD ${binary_name} /usr/local/bin/${binary_name}\n" > ${docker_file_path}
|
||||||
|
|
||||||
if [[ ${arch} == "amd64" ]]; then
|
if [[ ${arch} == "amd64" ]]; then
|
||||||
# If we are building a amd64 docker image, preserve the original image name
|
# If we are building a amd64 docker image, preserve the original
|
||||||
local docker_image_tag="gcr.io/google_containers/${binary_name}:${docker_tag}"
|
# image name
|
||||||
|
docker_image_tag+="/${binary_name}:${docker_tag}"
|
||||||
else
|
else
|
||||||
# If we are building a docker image for another architecture, append the arch in the image tag
|
# If we are building a docker image for another architecture,
|
||||||
local docker_image_tag="gcr.io/google_containers/${binary_name}-${arch}:${docker_tag}"
|
# append the arch in the image tag
|
||||||
|
docker_image_tag+="/${binary_name}-${arch}:${docker_tag}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
"${DOCKER[@]}" build --pull -q -t "${docker_image_tag}" ${docker_build_path} >/dev/null
|
"${DOCKER[@]}" build --pull -q -t "${docker_image_tag}" ${docker_build_path} >/dev/null
|
||||||
|
@ -307,13 +310,16 @@ function kube::release::create_docker_images_for_server() {
|
||||||
|
|
||||||
rm -rf ${docker_build_path}
|
rm -rf ${docker_build_path}
|
||||||
|
|
||||||
# If we are building an official/alpha/beta release we want to keep docker images
|
# If we are building an official/alpha/beta release we want to keep
|
||||||
# and tag them appropriately.
|
# docker images and tag them appropriately.
|
||||||
if [[ -n "${KUBE_DOCKER_IMAGE_TAG-}" && -n "${KUBE_DOCKER_REGISTRY-}" ]]; then
|
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}"
|
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}"
|
# Only rmi and tag if name is different
|
||||||
"${DOCKER[@]}" rmi "${release_docker_image_tag}" 2>/dev/null || true
|
if [[ $docker_image_tag != $release_docker_image_tag ]]; then
|
||||||
"${DOCKER[@]}" tag "${docker_image_tag}" "${release_docker_image_tag}" 2>/dev/null
|
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
|
fi
|
||||||
|
|
||||||
kube::log::status "Deleting docker image ${docker_image_tag}"
|
kube::log::status "Deleting docker image ${docker_image_tag}"
|
||||||
|
|
Loading…
Reference in New Issue