Skip to content

Commit 8314bd2

Browse files
committed
Build multi-arch images for ARM64 and AMD64 at the same time
We can use buildx, which is already set up in the Makefile, to simultaneously build a multi-arch Docker image for this component for ARM64 and AMD64, such that the image will work for both architectures.
1 parent dbe766c commit 8314bd2

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

Dockerfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
FROM golang:1.13.15 as builder
1616
WORKDIR /go/src/sigs.k8s.io/gcp-compute-persistent-disk-csi-driver
1717
ADD . .
18-
RUN make
18+
RUN make gce-pd-driver
1919

2020
# MAD HACKS: Build a version first so we can take the scsi_id bin and put it somewhere else in our real build
21-
FROM k8s.gcr.io/build-image/debian-base-amd64:v2.1.3 as base
21+
FROM k8s.gcr.io/build-image/debian-base:v2.1.3 as base
2222
RUN clean-install udev
2323

2424
# Start from Kubernetes Debian base
25-
FROM k8s.gcr.io/build-image/debian-base-amd64:v2.1.3
25+
FROM k8s.gcr.io/build-image/debian-base:v2.1.3
2626
COPY --from=builder /go/src/sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/bin/gce-pd-csi-driver /gce-pd-csi-driver
2727
# Install necessary dependencies
2828
RUN clean-install util-linux e2fsprogs mount ca-certificates udev xfsprogs

Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ push-container: build-container
8080
gcloud docker -- push $(STAGINGIMAGE):$(STAGINGVERSION)
8181

8282
build-and-push-container-linux: require-GCE_PD_CSI_STAGING_IMAGE init-buildx
83-
$(DOCKER) buildx build --platform=linux \
83+
$(DOCKER) buildx build --platform=linux/amd64,linux/arm64 \
8484
-t $(STAGINGIMAGE):$(STAGINGVERSION)_linux \
8585
--build-arg TAG=$(STAGINGVERSION) --push .
8686

@@ -97,8 +97,8 @@ endif
9797

9898
init-buildx:
9999
# Ensure we use a builder that can leverage it (the default on linux will not)
100-
-$(DOCKER) buildx rm windows-builder
101-
$(DOCKER) buildx create --use --name=windows-builder
100+
-$(DOCKER) buildx rm multiarch-multiplatform-builder
101+
$(DOCKER) buildx create --use --name=multiarch-multiplatform-builder
102102
# Register gcloud as a Docker credential helper.
103103
# Required for "docker buildx build --push".
104104
gcloud auth configure-docker --quiet

0 commit comments

Comments
 (0)