diff --git a/build/lib/release.sh b/build/lib/release.sh index 8e5422d503c..58383cede7a 100644 --- a/build/lib/release.sh +++ b/build/lib/release.sh @@ -364,7 +364,7 @@ function kube::release::create_docker_images_for_server() { local base_image=${wrappable##*,} local binary_file_path="${binary_dir}/${binary_name}" local docker_build_path="${binary_file_path}.dockerbuild" - local docker_file_path="${docker_build_path}/Dockerfile" + local docker_file_path="${KUBE_ROOT}/build/server-image/Dockerfile" local docker_image_tag="${docker_registry}/${binary_name}-${arch}:${docker_tag}" kube::log::status "Starting docker build for image: ${binary_name}-${arch}" @@ -372,22 +372,15 @@ function kube::release::create_docker_images_for_server() { rm -rf "${docker_build_path}" mkdir -p "${docker_build_path}" ln "${binary_file_path}" "${docker_build_path}/${binary_name}" - ln "${KUBE_ROOT}/build/nsswitch.conf" "${docker_build_path}/nsswitch.conf" - chmod 0644 "${docker_build_path}/nsswitch.conf" - cat < "${docker_file_path}" -FROM ${base_image} -COPY ${binary_name} /usr/local/bin/${binary_name} -EOF - # ensure /etc/nsswitch.conf exists so go's resolver respects /etc/hosts - if [[ "${base_image}" =~ busybox ]]; then - echo "COPY nsswitch.conf /etc/" >> "${docker_file_path}" - fi local build_log="${docker_build_path}/build.log" if ! DOCKER_CLI_EXPERIMENTAL=enabled "${DOCKER[@]}" buildx build \ + -f "${docker_file_path}" \ --platform linux/"${arch}" \ --load ${docker_build_opts:+"${docker_build_opts}"} \ -t "${docker_image_tag}" \ + --build-arg BASEIMAGE="${base_image}" \ + --build-arg BINARY="${binary_name}" \ "${docker_build_path}" >"${build_log}" 2>&1; then cat "${build_log}" exit 1 diff --git a/build/server-image/Dockerfile b/build/server-image/Dockerfile new file mode 100644 index 00000000000..3ae6a287166 --- /dev/null +++ b/build/server-image/Dockerfile @@ -0,0 +1,21 @@ +# Copyright 2021 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Dockerfile used for the server images. + +ARG BASEIMAGE +ARG BINARY + +FROM ${BASEIMAGE} +COPY ${BINARY} /usr/local/bin/${BINARY} \ No newline at end of file