mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 04:33:26 +00:00
Only register qemu-user-static when necessary.
Also, don't re-download qemu-ARCH-static binaries for debian-iptables
This commit is contained in:
parent
92fc7f18a2
commit
0dee9f150b
@ -51,8 +51,10 @@ endif
|
|||||||
mkdir -p ${TEMP_DIR}/cni-bin/bin
|
mkdir -p ${TEMP_DIR}/cni-bin/bin
|
||||||
tar -xz -C ${TEMP_DIR}/cni-bin/bin -f "cni-tars/${CNI_TARBALL}"
|
tar -xz -C ${TEMP_DIR}/cni-bin/bin -f "cni-tars/${CNI_TARBALL}"
|
||||||
|
|
||||||
|
ifneq ($(ARCH),amd64)
|
||||||
# Register /usr/bin/qemu-ARCH-static as the handler for non-x86 binaries in the kernel
|
# Register /usr/bin/qemu-ARCH-static as the handler for non-x86 binaries in the kernel
|
||||||
docker run --rm --privileged multiarch/qemu-user-static:register --reset
|
docker run --rm --privileged multiarch/qemu-user-static:register --reset
|
||||||
|
endif
|
||||||
docker build --pull -t $(REGISTRY)/$(IMAGE)-$(ARCH):$(TAG) $(TEMP_DIR)
|
docker build --pull -t $(REGISTRY)/$(IMAGE)-$(ARCH):$(TAG) $(TEMP_DIR)
|
||||||
rm -rf $(TEMP_DIR)
|
rm -rf $(TEMP_DIR)
|
||||||
|
|
||||||
|
@ -14,10 +14,6 @@
|
|||||||
|
|
||||||
FROM BASEIMAGE
|
FROM BASEIMAGE
|
||||||
|
|
||||||
# If we're building for another architecture than amd64, the CROSS_BUILD_ placeholder is removed so e.g. CROSS_BUILD_COPY turns into COPY
|
|
||||||
# If we're building normally, for amd64, CROSS_BUILD lines are removed
|
|
||||||
CROSS_BUILD_COPY qemu-ARCH-static /usr/bin/
|
|
||||||
|
|
||||||
RUN clean-install \
|
RUN clean-install \
|
||||||
conntrack \
|
conntrack \
|
||||||
ebtables \
|
ebtables \
|
||||||
|
@ -19,37 +19,16 @@ IMAGE=debian-iptables
|
|||||||
TAG=v10.1
|
TAG=v10.1
|
||||||
ARCH?=amd64
|
ARCH?=amd64
|
||||||
TEMP_DIR:=$(shell mktemp -d)
|
TEMP_DIR:=$(shell mktemp -d)
|
||||||
QEMUVERSION=v2.9.1
|
|
||||||
|
|
||||||
ifeq ($(ARCH),arm)
|
|
||||||
QEMUARCH=arm
|
|
||||||
endif
|
|
||||||
ifeq ($(ARCH),arm64)
|
|
||||||
QEMUARCH=aarch64
|
|
||||||
endif
|
|
||||||
ifeq ($(ARCH),ppc64le)
|
|
||||||
QEMUARCH=ppc64le
|
|
||||||
endif
|
|
||||||
ifeq ($(ARCH),s390x)
|
|
||||||
QEMUARCH=s390x
|
|
||||||
endif
|
|
||||||
|
|
||||||
BASEIMAGE=k8s.gcr.io/debian-base-$(ARCH):0.3.1
|
BASEIMAGE=k8s.gcr.io/debian-base-$(ARCH):0.3.1
|
||||||
|
|
||||||
build:
|
build:
|
||||||
cp ./* $(TEMP_DIR)
|
cp ./* $(TEMP_DIR)
|
||||||
cd $(TEMP_DIR) && sed -i "s|BASEIMAGE|$(BASEIMAGE)|g" Dockerfile
|
cd $(TEMP_DIR) && sed -i "s|BASEIMAGE|$(BASEIMAGE)|g" Dockerfile
|
||||||
cd $(TEMP_DIR) && sed -i "s|ARCH|$(QEMUARCH)|g" Dockerfile
|
|
||||||
|
|
||||||
ifeq ($(ARCH),amd64)
|
ifneq ($(ARCH),amd64)
|
||||||
# When building "normally" for amd64, remove the whole line, it has no part in the amd64 image
|
# Register /usr/bin/qemu-ARCH-static as the handler for non-x86 binaries in the kernel
|
||||||
cd $(TEMP_DIR) && sed -i "/CROSS_BUILD_/d" Dockerfile
|
|
||||||
else
|
|
||||||
# When cross-building, only the placeholder "CROSS_BUILD_" should be removed
|
|
||||||
# Register /usr/bin/qemu-ARCH-static as the handler for ARM binaries in the kernel
|
|
||||||
docker run --rm --privileged multiarch/qemu-user-static:register --reset
|
docker run --rm --privileged multiarch/qemu-user-static:register --reset
|
||||||
curl -sSL https://github.com/multiarch/qemu-user-static/releases/download/$(QEMUVERSION)/x86_64_qemu-$(QEMUARCH)-static.tar.gz | tar -xz -C $(TEMP_DIR)
|
|
||||||
cd $(TEMP_DIR) && sed -i "s/CROSS_BUILD_//g" Dockerfile
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
docker build --pull -t $(REGISTRY)/$(IMAGE)-$(ARCH):$(TAG) $(TEMP_DIR)
|
docker build --pull -t $(REGISTRY)/$(IMAGE)-$(ARCH):$(TAG) $(TEMP_DIR)
|
||||||
|
@ -39,8 +39,10 @@ endif
|
|||||||
|
|
||||||
cd ${TEMP_DIR} && sed -i.back "s|BASEIMAGE|${BASEIMAGE}|g" Dockerfile
|
cd ${TEMP_DIR} && sed -i.back "s|BASEIMAGE|${BASEIMAGE}|g" Dockerfile
|
||||||
|
|
||||||
|
ifneq ($(ARCH),amd64)
|
||||||
# Register /usr/bin/qemu-ARCH-static as the handler for non-x86 binaries in the kernel
|
# Register /usr/bin/qemu-ARCH-static as the handler for non-x86 binaries in the kernel
|
||||||
docker run --rm --privileged multiarch/qemu-user-static:register --reset
|
docker run --rm --privileged multiarch/qemu-user-static:register --reset
|
||||||
|
endif
|
||||||
docker build --pull -t ${REGISTRY}/hyperkube-${ARCH}:${VERSION} ${TEMP_DIR}
|
docker build --pull -t ${REGISTRY}/hyperkube-${ARCH}:${VERSION} ${TEMP_DIR}
|
||||||
rm -rf "${TEMP_DIR}"
|
rm -rf "${TEMP_DIR}"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user