mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-10 13:42:02 +00:00
Cleanup output of Docker builds, fix #6389
This commit is contained in:
@@ -586,26 +586,34 @@ function kube::release::package_server_tarballs() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function kube::release::md5() {
|
||||||
|
if which md5 >/dev/null 2>&1; then
|
||||||
|
md5 -q "$1"
|
||||||
|
else
|
||||||
|
md5sum "$1" | awk '{ print $1 }'
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# This will take binaries that run on master and creates Docker images
|
# This will take binaries that run on master and creates Docker images
|
||||||
# that wrap the binary in them. (One docker image per binary)
|
# that wrap the binary in them. (One docker image per binary)
|
||||||
function kube::release::create_docker_images_for_server() {
|
function kube::release::create_docker_images_for_server() {
|
||||||
# Create a sub-shell so that we don't pollute the outer environment
|
# Create a sub-shell so that we don't pollute the outer environment
|
||||||
(
|
(
|
||||||
local binary_name;
|
local binary_name
|
||||||
for binary_name in "${KUBE_DOCKER_WRAPPED_BINARIES[@]}"; do
|
for binary_name in "${KUBE_DOCKER_WRAPPED_BINARIES[@]}"; do
|
||||||
echo "+++ Building docker image: ${binary_name}";
|
kube::log::status "Building docker image: ${binary_name}"
|
||||||
local docker_file_path="$1/Dockerfile";
|
local docker_file_path="$1/Dockerfile"
|
||||||
local binary_file_path="$1/${binary_name}";
|
local binary_file_path="$1/${binary_name}"
|
||||||
if [ -f ${docker_file_path} ]; then
|
if [ -f ${docker_file_path} ]; then
|
||||||
rm ${docker_file_path};
|
rm ${docker_file_path}
|
||||||
fi;
|
fi
|
||||||
printf " FROM scratch \n ADD ${binary_name} /${binary_name} \n ENTRYPOINT [ \"/${binary_name}\" ]\n" >> ${docker_file_path};
|
printf " FROM scratch \n ADD ${binary_name} /${binary_name} \n ENTRYPOINT [ \"/${binary_name}\" ]\n" >> ${docker_file_path}
|
||||||
local md5_sum=$(md5sum ${binary_file_path} | awk '{print $1}')
|
local md5_sum=$(kube::release::md5 ${binary_file_path})
|
||||||
local docker_image_tag=gcr.io/google_containers/$binary_name:$md5_sum
|
local docker_image_tag=gcr.io/google_containers/$binary_name:$md5_sum
|
||||||
docker build -t "${docker_image_tag}" ${1};
|
docker build -q -t "${docker_image_tag}" ${1} >/dev/null
|
||||||
docker save ${docker_image_tag} > ${1}/${binary_name}.tar;
|
docker save ${docker_image_tag} > ${1}/${binary_name}.tar
|
||||||
echo $md5_sum > ${1}/${binary_name}.docker_tag;
|
echo $md5_sum > ${1}/${binary_name}.docker_tag
|
||||||
rm ${docker_file_path};
|
rm ${docker_file_path}
|
||||||
done
|
done
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user