|
12 | 12 | # See the License for the specific language governing permissions and |
13 | 13 | # limitations under the License. |
14 | 14 |
|
15 | | -# Makefile for the Docker image gcr.io/google_containers/dnsmasq |
| 15 | +# Makefile for the Docker image gcr.io/google_containers/kube-dnsmasq-ARCH |
16 | 16 | # MAINTAINER: Abhishek Shah <[email protected]> |
17 | 17 | # If you update this image please bump the tag value before pushing. |
18 | 18 | # |
19 | 19 | # Usage: |
20 | | -# [TAG=1.0] [REGISTRY=gcr.io/google_containers] [NAMESERVER=127.0.0.1#10053] make container |
| 20 | +# [TAG=1.3] [REGISTRY=gcr.io/google_containers] make (build|push) |
21 | 21 |
|
22 | 22 | # Default registry, arch and tag. This can be overwritten by arguments to make |
23 | | -TAG?=1.2 |
| 23 | +TAG?=1.3 |
24 | 24 | REGISTRY?=gcr.io/google_containers |
25 | 25 | ARCH?=amd64 |
26 | 26 | KUBE_CROSS_IMAGE:=$(REGISTRY)/kube-cross:v1.6.2-2 |
27 | 27 | DNSMASQ_VERSION?=dnsmasq-2.76 |
28 | 28 | TEMP_DIR:=$(shell mktemp -d) |
29 | 29 |
|
30 | | -ifeq ($(ARCH),amd64) |
31 | | - BASEIMAGE?=alpine:3.4 |
32 | | -else |
33 | | - BASEIMAGE?=$(REGISTRY)/tiny-glibc-$(ARCH):1.0 |
34 | | -endif |
35 | | - |
36 | 30 | ifeq ($(ARCH),arm) |
| 31 | + BASEIMAGE?=armel/busybox:glibc |
37 | 32 | TRIPLE?=arm-linux-gnueabi |
| 33 | + QEMUARCH=arm |
38 | 34 | endif |
39 | 35 | ifeq ($(ARCH),arm64) |
| 36 | + BASEIMAGE?=aarch64/busybox:glibc |
40 | 37 | TRIPLE?=aarch64-linux-gnu |
| 38 | + QEMUARCH=aarch64 |
41 | 39 | endif |
42 | 40 | ifeq ($(ARCH),ppc64le) |
| 41 | + BASEIMAGE?=ppc64le/busybox:glibc |
43 | 42 | TRIPLE?=powerpc64le-linux-gnu |
| 43 | + QEMUARCH=ppc64le |
44 | 44 | endif |
45 | 45 |
|
46 | 46 | all: build |
47 | 47 |
|
48 | 48 | build: |
49 | 49 | ifeq ($(ARCH),amd64) |
50 | 50 | 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 |
51 | 53 | else |
52 | 54 | cp Dockerfile.cross $(TEMP_DIR)/Dockerfile |
53 | | - 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 |
54 | 57 |
|
55 | 58 | # Build the dnsmasq binary using the cross-compilation docker image |
56 | 59 | docker run -it --rm -v $(TEMP_DIR):/build $(KUBE_CROSS_IMAGE) /bin/bash -c \ |
57 | 60 | "curl -sSL http://www.thekelleys.org.uk/dnsmasq/$(DNSMASQ_VERSION).tar.xz | tar -xJ \ |
58 | 61 | && cd $(DNSMASQ_VERSION) \ |
59 | 62 | && CC=$(TRIPLE)-gcc make \ |
60 | 63 | && 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 |
61 | 70 | endif |
62 | 71 | cp dnsmasq.conf $(TEMP_DIR) |
63 | 72 | docker build -t $(REGISTRY)/kube-dnsmasq-$(ARCH):$(TAG) $(TEMP_DIR) |
|
0 commit comments