@@ -23,6 +23,7 @@ all: build
23
23
24
24
# PLATFORMS is the set of OS_ARCH that NPD can build against.
25
25
LINUX_PLATFORMS =linux_amd64 linux_arm64
26
+ DOCKER_PLATFORMS =linux/amd64,linux/arm64
26
27
PLATFORMS =$(LINUX_PLATFORMS ) windows_amd64
27
28
28
29
# VERSION is the version of the binary.
74
75
# The debian-base:v1.0.0 image built from kubernetes repository is based on
75
76
# Debian Stretch. It includes systemd 232 with support for both +XZ and +LZ4
76
77
# compression. +LZ4 is needed on some os distros such as COS.
77
- BASEIMAGE: =k8s.gcr.io/debian-base-amd64 :v2.0.0
78
+ BASEIMAGE: =k8s.gcr.io/debian-base:v2.0.0
78
79
79
80
# Disable cgo by default to make the binary statically linked.
80
81
CGO_ENABLED: =0
@@ -239,8 +240,9 @@ $(NPD_NAME_VERSION)-%.tar.gz: $(ALL_BINARIES) test/e2e-install.sh
239
240
240
241
build-binaries : $(ALL_BINARIES )
241
242
242
- build-container : build-binaries Dockerfile
243
- docker build -t $(IMAGE ) --build-arg BASEIMAGE=$(BASEIMAGE ) --build-arg LOGCOUNTER=$(LOGCOUNTER ) .
243
+ build-container : clean Dockerfile
244
+ docker buildx create --use
245
+ docker buildx build --platform $(DOCKER_PLATFORMS ) -t $(IMAGE ) --build-arg BASEIMAGE=$(BASEIMAGE ) --build-arg LOGCOUNTER=$(LOGCOUNTER ) .
244
246
245
247
$(TARBALL ) : ./bin/node-problem-detector ./bin/log-counter ./bin/health-checker ./test/bin/problem-maker
246
248
tar -zcvf $(TARBALL ) bin/ config/ test/e2e-install.sh test/bin/problem-maker
@@ -252,16 +254,21 @@ build-tar: $(TARBALL) $(ALL_TARBALLS)
252
254
build : build-container build-tar
253
255
254
256
docker-builder :
255
- docker build -t npd-builder ./ builder
257
+ docker build -t npd-builder . --target= builder
256
258
257
259
build-in-docker : clean docker-builder
258
260
docker run \
259
261
-v ` pwd` :/gopath/src/k8s.io/node-problem-detector/ npd-builder:latest bash \
260
262
-c ' cd /gopath/src/k8s.io/node-problem-detector/ && make build-binaries'
261
263
262
264
push-container : build-container
265
+ # So we can push to docker hub by setting REGISTRY
266
+ ifneq (,$(findstring gcr.io,$(REGISTRY ) ) )
263
267
gcloud auth configure-docker
264
- docker push $(IMAGE )
268
+ endif
269
+ # Build should be cached from build-container
270
+ docker buildx create --use
271
+ docker buildx build --push --platform $(DOCKER_PLATFORMS) -t $(IMAGE) --build-arg BASEIMAGE=$(BASEIMAGE) --build-arg LOGCOUNTER=$(LOGCOUNTER) .
265
272
266
273
push-tar : build-tar
267
274
gsutil cp $(TARBALL ) $(UPLOAD_PATH ) /node-problem-detector/
0 commit comments