mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 20:24:09 +00:00
Use on disk Dockerfile for server-images.
This commit is contained in:
parent
b2b8c1f18d
commit
94f30808ae
@ -364,7 +364,7 @@ function kube::release::create_docker_images_for_server() {
|
|||||||
local base_image=${wrappable##*,}
|
local base_image=${wrappable##*,}
|
||||||
local binary_file_path="${binary_dir}/${binary_name}"
|
local binary_file_path="${binary_dir}/${binary_name}"
|
||||||
local docker_build_path="${binary_file_path}.dockerbuild"
|
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}"
|
local docker_image_tag="${docker_registry}/${binary_name}-${arch}:${docker_tag}"
|
||||||
|
|
||||||
kube::log::status "Starting docker build for image: ${binary_name}-${arch}"
|
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}"
|
rm -rf "${docker_build_path}"
|
||||||
mkdir -p "${docker_build_path}"
|
mkdir -p "${docker_build_path}"
|
||||||
ln "${binary_file_path}" "${docker_build_path}/${binary_name}"
|
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 <<EOF > "${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"
|
local build_log="${docker_build_path}/build.log"
|
||||||
if ! DOCKER_CLI_EXPERIMENTAL=enabled "${DOCKER[@]}" buildx build \
|
if ! DOCKER_CLI_EXPERIMENTAL=enabled "${DOCKER[@]}" buildx build \
|
||||||
|
-f "${docker_file_path}" \
|
||||||
--platform linux/"${arch}" \
|
--platform linux/"${arch}" \
|
||||||
--load ${docker_build_opts:+"${docker_build_opts}"} \
|
--load ${docker_build_opts:+"${docker_build_opts}"} \
|
||||||
-t "${docker_image_tag}" \
|
-t "${docker_image_tag}" \
|
||||||
|
--build-arg BASEIMAGE="${base_image}" \
|
||||||
|
--build-arg BINARY="${binary_name}" \
|
||||||
"${docker_build_path}" >"${build_log}" 2>&1; then
|
"${docker_build_path}" >"${build_log}" 2>&1; then
|
||||||
cat "${build_log}"
|
cat "${build_log}"
|
||||||
exit 1
|
exit 1
|
||||||
|
21
build/server-image/Dockerfile
Normal file
21
build/server-image/Dockerfile
Normal file
@ -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}
|
Loading…
Reference in New Issue
Block a user