Skip to content
This repository was archived by the owner on Apr 17, 2019. It is now read-only.

Commit f773ef1

Browse files
committed
Fix the mkdir statement
1 parent a50f34a commit f773ef1

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

dnsmasq/Dockerfile.cross

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
# limitations under the License.
1414

1515
FROM BASEIMAGE
16+
# If we're building for another architecture than amd64, the CROSS_BUILD_ placeholder is removed so e.g. CROSS_BUILD_COPY turns into COPY
17+
# If we're building normally, for amd64, CROSS_BUILD lines are removed
18+
CROSS_BUILD_COPY qemu-ARCH-static /usr/bin/
1619
MAINTAINER Girish Kalele <[email protected]>
1720
COPY dnsmasq.conf /etc/dnsmasq.conf
1821
COPY dnsmasq /usr/sbin/dnsmasq
19-
20-
# This is just a mkdir statement for /var/run in order to keep the complexity of the Makefile down
21-
WORKDIR /var/run
22-
WORKDIR /
22+
RUN mkdir /var/run/
2323
ENTRYPOINT ["/usr/sbin/dnsmasq", "--keep-in-foreground"]

dnsmasq/Makefile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,31 +30,43 @@ TEMP_DIR:=$(shell mktemp -d)
3030
ifeq ($(ARCH),arm)
3131
BASEIMAGE?=armel/busybox:glibc
3232
TRIPLE?=arm-linux-gnueabi
33+
QEMUARCH=arm
3334
endif
3435
ifeq ($(ARCH),arm64)
3536
BASEIMAGE?=aarch64/busybox:glibc
3637
TRIPLE?=aarch64-linux-gnu
38+
QEMUARCH=aarch64
3739
endif
3840
ifeq ($(ARCH),ppc64le)
3941
BASEIMAGE?=ppc64le/busybox:glibc
4042
TRIPLE?=powerpc64le-linux-gnu
43+
QEMUARCH=ppc64le
4144
endif
4245

4346
all: build
4447

4548
build:
4649
ifeq ($(ARCH),amd64)
4750
cp Dockerfile $(TEMP_DIR)
51+
# When building "normally" for amd64, remove the whole line, it has no part in the amd64 image
52+
cd $(TEMP_DIR) && sed -i "/CROSS_BUILD_/d" Dockerfile
4853
else
4954
cp Dockerfile.cross $(TEMP_DIR)/Dockerfile
50-
sed -i "s|BASEIMAGE|$(BASEIMAGE)|g" $(TEMP_DIR)/Dockerfile
55+
cd $(TEMP_DIR) && sed -i "s|BASEIMAGE|$(BASEIMAGE)|g" Dockerfile
56+
cd $(TEMP_DIR) && sed -i "s|ARCH|$(QEMUARCH)|g" Dockerfile
5157

5258
# Build the dnsmasq binary using the cross-compilation docker image
5359
docker run -it --rm -v $(TEMP_DIR):/build $(KUBE_CROSS_IMAGE) /bin/bash -c \
5460
"curl -sSL http://www.thekelleys.org.uk/dnsmasq/$(DNSMASQ_VERSION).tar.xz | tar -xJ \
5561
&& cd $(DNSMASQ_VERSION) \
5662
&& CC=$(TRIPLE)-gcc make \
5763
&& cp src/dnsmasq /build"
64+
65+
# When cross-building, only the placeholder "CROSS_BUILD_" should be removed
66+
# Register /usr/bin/qemu-ARCH-static as the handler for ARM binaries in the kernel
67+
docker run --rm --privileged multiarch/qemu-user-static:register --reset
68+
curl -sSL https://github.com/multiarch/qemu-user-static/releases/download/v2.5.0/x86_64_qemu-$(QEMUARCH)-static.tar.xz | tar -xJ -C $(TEMP_DIR)
69+
cd $(TEMP_DIR) && sed -i "s/CROSS_BUILD_//g" Dockerfile
5870
endif
5971
cp dnsmasq.conf $(TEMP_DIR)
6072
docker build -t $(REGISTRY)/kube-dnsmasq-$(ARCH):$(TAG) $(TEMP_DIR)

0 commit comments

Comments
 (0)