From 9a6e04dc1f896b27ff4193c45eeb3a3107338cfa Mon Sep 17 00:00:00 2001 From: Zach Loafman Date: Thu, 2 Apr 2015 18:18:24 -0700 Subject: [PATCH] Cleanup output of Docker builds, fix #6389 --- build/common.sh | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/build/common.sh b/build/common.sh index 5f52e6381ded5..7548acfcc55ad 100644 --- a/build/common.sh +++ b/build/common.sh @@ -586,26 +586,34 @@ function kube::release::package_server_tarballs() { 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 # that wrap the binary in them. (One docker image per binary) function kube::release::create_docker_images_for_server() { # 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 - echo "+++ Building docker image: ${binary_name}"; - local docker_file_path="$1/Dockerfile"; - local binary_file_path="$1/${binary_name}"; + kube::log::status "Building docker image: ${binary_name}" + local docker_file_path="$1/Dockerfile" + local binary_file_path="$1/${binary_name}" if [ -f ${docker_file_path} ]; then - rm ${docker_file_path}; - fi; - 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}') + rm ${docker_file_path} + fi + printf " FROM scratch \n ADD ${binary_name} /${binary_name} \n ENTRYPOINT [ \"/${binary_name}\" ]\n" >> ${docker_file_path} + local md5_sum=$(kube::release::md5 ${binary_file_path}) local docker_image_tag=gcr.io/google_containers/$binary_name:$md5_sum - docker build -t "${docker_image_tag}" ${1}; - docker save ${docker_image_tag} > ${1}/${binary_name}.tar; - echo $md5_sum > ${1}/${binary_name}.docker_tag; - rm ${docker_file_path}; + docker build -q -t "${docker_image_tag}" ${1} >/dev/null + docker save ${docker_image_tag} > ${1}/${binary_name}.tar + echo $md5_sum > ${1}/${binary_name}.docker_tag + rm ${docker_file_path} done ) }