Skip to content

Commit 5fb0a3c

Browse files
committed
Multiarch build improved
1 parent d4f1dbb commit 5fb0a3c

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# Initialized TARGETPLATFORM with default value
16+
ARG TARGETPLATFORM=linux/amd64
17+
1518
FROM golang:1.17 AS builder
1619
WORKDIR /go/src/sigs.k8s.io/ibm-powervs-block-csi-driver
1720
ADD . .
18-
RUN make driver node-update-controller
21+
RUN GOARCH=$(echo $TARGETPLATFORM | cut -f2 -d '/') make driver node-update-controller
1922

2023
# debian base image
2124
FROM k8s.gcr.io/build-image/debian-base:v2.1.3 AS debian-base
@@ -24,7 +27,7 @@ COPY --from=builder /go/src/sigs.k8s.io/ibm-powervs-block-csi-driver/bin/* /
2427
ENTRYPOINT ["/ibm-powervs-block-csi-driver"]
2528

2629
# centos base image
27-
FROM quay.io/centos/centos:stream8 AS centos-base
30+
FROM --platform=$TARGETPLATFORM quay.io/centos/centos:stream8 AS centos-base
2831
RUN yum install -y util-linux nfs-utils e2fsprogs xfsprogs ca-certificates && yum clean all && rm -rf /var/cache/yum
2932
COPY --from=builder /go/src/sigs.k8s.io/ibm-powervs-block-csi-driver/bin/* /
3033
ENTRYPOINT ["/ibm-powervs-block-csi-driver"]

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ test:
4545

4646
.PHONY: image
4747
image:
48-
docker build -t $(REGISTRY)/$(IMG):$(TAG) . --target debian-base
48+
docker build -t $(REGISTRY)/$(IMG):$(TAG) . --target centos-base
4949

5050
.PHONY: push
5151
push:
@@ -55,16 +55,16 @@ build-image-and-push-linux-amd64: init-buildx
5555
{ \
5656
set -e ; \
5757
docker buildx build \
58-
--platform linux/amd64 \
59-
-t $(REGISTRY)/$(IMG):$(TAG)_linux_amd64 --push . --target debian-base; \
58+
--build-arg TARGETPLATFORM=linux/amd64 \
59+
-t $(REGISTRY)/$(IMG):$(TAG)_linux_amd64 --push . --target centos-base; \
6060
}
6161

6262
build-image-and-push-linux-ppc64le: init-buildx
6363
{ \
6464
set -e ; \
6565
docker buildx build \
66-
--platform linux/ppc64le \
67-
-t $(REGISTRY)/$(IMG):$(TAG)_linux_ppc64le --push . --target debian-base; \
66+
--build-arg TARGETPLATFORM=linux/ppc64le \
67+
-t $(REGISTRY)/$(IMG):$(TAG)_linux_ppc64le --push . --target centos-base; \
6868
}
6969

7070
build-and-push-multi-arch: build-image-and-push-linux-amd64 build-image-and-push-linux-ppc64le

0 commit comments

Comments
 (0)