Skip to content

Commit

Permalink
Cleanup output of Docker builds, fix kubernetes#6389
Browse files Browse the repository at this point in the history
  • Loading branch information
zmerlynn committed Apr 3, 2015
1 parent 03c7182 commit 9a6e04d
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions build/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
}
Expand Down

0 comments on commit 9a6e04d

Please sign in to comment.