Skip to content

Commit e689d51

Browse files
authored
Merge pull request kubernetes#71634 from ereslibre/allow-to-build-images-offline
Allow to build docker images offline (do not always use `docker build --pull`)
2 parents 82cefcd + 68e6fa0 commit e689d51

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

build/lib/release.sh

+10-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ readonly RELEASE_IMAGES="${LOCAL_OUTPUT_ROOT}/release-images"
3030

3131
KUBE_BUILD_HYPERKUBE=${KUBE_BUILD_HYPERKUBE:-y}
3232
KUBE_BUILD_CONFORMANCE=${KUBE_BUILD_CONFORMANCE:-y}
33+
KUBE_BUILD_PULL_LATEST_IMAGES=${KUBE_BUILD_PULL_LATEST_IMAGES:-y}
3334

3435
# Validate a ci version
3536
#
@@ -372,7 +373,15 @@ EOF
372373
if [[ "${base_image}" =~ busybox ]]; then
373374
echo "COPY nsswitch.conf /etc/" >> "${docker_file_path}"
374375
fi
375-
"${DOCKER[@]}" build --pull -q -t "${docker_image_tag}" "${docker_build_path}" >/dev/null
376+
377+
# provide `--pull` argument to `docker build` if `KUBE_BUILD_PULL_LATEST_IMAGES`
378+
# is set to y or Y; otherwise try to build the image without forcefully
379+
# pulling the latest base image.
380+
local -a docker_build_opts=()
381+
if [[ "${KUBE_BUILD_PULL_LATEST_IMAGES}" =~ [yY] ]]; then
382+
docker_build_opts+=("--pull")
383+
fi
384+
"${DOCKER[@]}" build "${docker_build_opts[@]}" -q -t "${docker_image_tag}" "${docker_build_path}" >/dev/null
376385
"${DOCKER[@]}" save "${docker_image_tag}" > "${binary_dir}/${binary_name}.tar"
377386
echo "${docker_tag}" > "${binary_dir}/${binary_name}.docker_tag"
378387
rm -rf "${docker_build_path}"

0 commit comments

Comments
 (0)