From 954edb1c005e16fb323116c22c8a100a02c43256 Mon Sep 17 00:00:00 2001 From: Peter Kurfer Date: Sat, 9 Nov 2024 09:30:04 +0100 Subject: [PATCH] chore(make): use buildx to build multi-arch image --- Dockerfile | 6 +++--- Makefile | 5 +---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6a84168..5dfba55 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.19-alpine as gobuild +FROM golang:1.19-alpine AS gobuild WORKDIR /build ADD go.mod go.sum /build/ @@ -9,7 +9,7 @@ RUN CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' -o ./s FROM alpine:3.17 -ARG ARCH=amd64 +ARG BUILDARCH LABEL maintainers="Vitaliy Filippov " LABEL description="csi-s3 slim image" @@ -17,7 +17,7 @@ LABEL description="csi-s3 slim image" RUN apk add --no-cache fuse mailcap rclone RUN apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/community s3fs-fuse -ADD https://github.com/yandex-cloud/geesefs/releases/latest/download/geesefs-linux-${ARCH} /usr/bin/geesefs +ADD https://github.com/yandex-cloud/geesefs/releases/latest/download/geesefs-linux-${BUILDARCH} /usr/bin/geesefs RUN chmod 755 /usr/bin/geesefs COPY --from=gobuild /build/s3driver /s3driver diff --git a/Makefile b/Makefile index d0eadcb..704e2f0 100644 --- a/Makefile +++ b/Makefile @@ -27,10 +27,7 @@ test: docker build -t $(TEST_IMAGE_TAG) -f test/Dockerfile . docker run --rm --privileged -v $(PWD):/build --device /dev/fuse $(TEST_IMAGE_TAG) container: - docker buildx build --build-arg ARCH=amd64 --push --platform linux/amd64 -t $(IMAGE_TAG)-amd64 . - docker buildx build --build-arg ARCH=arm64 --push --platform linux/arm64 -t $(IMAGE_TAG)-arm64 . - docker manifest create --amend $(IMAGE_TAG) $(IMAGE_TAG)-amd64 $(IMAGE_TAG)-arm64 - docker manifest push --purge $(IMAGE_TAG) + docker buildx build --push --platform linux/amd64,linux/arm64 -t $(IMAGE_TAG) . push: container docker tag $(IMAGE_TAG) $(REGISTRY_NAME)/$(IMAGE_NAME):latest docker tag $(IMAGE_TAG) $(REGISTRY_NAME)/$(IMAGE_NAME2):$(VERSION)