Merge pull request #20398 from mfanjie/mfanjie-patch-1

Auto commit by PR queue bot
This commit is contained in:
k8s-merge-robot
2016-02-09 22:55:18 -08:00
3 changed files with 33 additions and 14 deletions

View File

@@ -189,7 +189,11 @@ function kube::build::prepare_docker_machine() {
kube::log::status "docker-machine was found."
docker-machine inspect "${DOCKER_MACHINE_NAME}" >/dev/null || {
kube::log::status "Creating a machine to build Kubernetes"
docker-machine create --driver "${DOCKER_MACHINE_DRIVER}" "${DOCKER_MACHINE_NAME}" > /dev/null || {
docker-machine create --driver "${DOCKER_MACHINE_DRIVER}" \
--engine-env HTTP_PROXY="${KUBE_BUILD_HTTP_PROXY:-}" \
--engine-env HTTPS_PROXY="${KUBE_BUILD_HTTPS_PROXY:-}" \
--engine-env NO_PROXY="${KUBE_BUILD_NO_PROXY:-127.0.0.1}" \
"${DOCKER_MACHINE_NAME}" > /dev/null || {
kube::log::error "Something went wrong creating a machine."
kube::log::error "Try the following: "
kube::log::error "docker-machine create -d ${DOCKER_MACHINE_DRIVER} ${DOCKER_MACHINE_NAME}"
@@ -233,6 +237,18 @@ function kube::build::is_osx() {
[[ "$(uname)" == "Darwin" ]]
}
function kube::build::update_dockerfile() {
if kube::build::is_osx; then
sed_opts=("-i ''")
else
sed_opts=(-i)
fi
sed ${sed_opts[@]} "s/KUBE_BUILD_IMAGE_CROSS/${KUBE_BUILD_IMAGE_CROSS}/" ${build_context_dir}/Dockerfile
sed ${sed_opts[@]} "s#KUBE_BUILD_HTTP_PROXY#${KUBE_BUILD_HTTP_PROXY:-\"\"}#" ${build_context_dir}/Dockerfile
sed ${sed_opts[@]} "s#KUBE_BUILD_HTTPS_PROXY#${KUBE_BUILD_HTTPS_PROXY:-\"\"}#" ${build_context_dir}/Dockerfile
sed ${sed_opts[@]} "s#KUBE_BUILD_NO_PROXY#${KUBE_BUILD_NO_PROXY:-127.0.0.1}#" ${build_context_dir}/Dockerfile
}
function kube::build::ensure_docker_in_path() {
if [[ -z "$(which docker)" ]]; then
kube::log::error "Can't find 'docker' in PATH, please fix and retry."
@@ -502,11 +518,8 @@ function kube::build::build_image() {
kube::version::save_version_vars "${build_context_dir}/kube-version-defs"
cp build/build-image/Dockerfile ${build_context_dir}/Dockerfile
if kube::build::is_osx; then
sed -i "" "s/KUBE_BUILD_IMAGE_CROSS/${KUBE_BUILD_IMAGE_CROSS}/" ${build_context_dir}/Dockerfile
else
sed -i "s/KUBE_BUILD_IMAGE_CROSS/${KUBE_BUILD_IMAGE_CROSS}/" ${build_context_dir}/Dockerfile
fi
kube::build::update_dockerfile
# We don't want to force-pull this image because it's based on a local image
# (see kube::build::build_image_cross), not upstream.
kube::build::docker_build "${KUBE_BUILD_IMAGE}" "${build_context_dir}" 'false'