From 414b588aa8646df0a5d3b1c41846d8a900120dba Mon Sep 17 00:00:00 2001 From: motoki317 Date: Sat, 15 Apr 2023 21:54:44 +0900 Subject: [PATCH 1/6] Use docker actions to build image instead of Makefile --- .github/workflows/release.yml | 40 +++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d3b2d76..10c4558 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,15 +5,51 @@ on: tags: - "v*" +env: + REGISTRY_NAME: cr.yandex/crp9ftr22d26age3hulg + REGISTRY_NAME2: cr.il.nebius.cloud/crll7us9n6i5j3v4n92m + IMAGE_NAME: csi-s3 + IMAGE_NAME2: yandex-cloud/csi-s3/csi-s3-driver + jobs: build: runs-on: ubuntu-latest steps: + - name: Set IMAGE_TAG env + # GITHUB_REF value: refs/heads/v* + run: echo "VERSION=$(echo ${GITHUB_REF:11})" >> $GITHUB_ENV + - uses: actions/checkout@v2 - - name: Push Docker - run: (echo '${{ secrets.REGISTRY_KEY }}' | docker login --username json_key --password-stdin cr.yandex) && make push + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + with: + platforms: all + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v2 + - name: Show available platforms + run: echo ${{ steps.buildx.outputs.platforms }} + + - name: Login to Registry + uses: docker/login-action@v2 + with: + registry: cr.yandex + username: json_key + password: ${{ secrets.REGISTRY_KEY }} + + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: . + push: true + platforms: linux/amd64 + tags: | + ${{ env.REGISTRY_NAME }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }} + ${{ env.REGISTRY_NAME }}/${{ env.IMAGE_NAME }}:latest + ${{ env.REGISTRY_NAME }}/${{ env.IMAGE_NAME2 }}:${{ env.VERSION }} + ${{ env.REGISTRY_NAME }}/${{ env.IMAGE_NAME2 }}:latest - uses: "marvinpinto/action-automatic-releases@latest" with: From 94d652a8d30f2b48bb9c6c1ba4d517f9ad7e305b Mon Sep 17 00:00:00 2001 From: motoki317 Date: Sat, 15 Apr 2023 23:57:05 +0900 Subject: [PATCH 2/6] Support linux/amd64 linux/arm64 build --- Dockerfile | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 94f181a..fe3c070 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,6 +7,16 @@ ADD cmd /build/cmd ADD pkg /build/pkg RUN CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' -o ./s3driver ./cmd/s3driver +FROM alpine:3.17 AS downloader + +WORKDIR /work + +RUN apk add --no-cache curl + +ARG TARGETPLATFORM +RUN ARCH=$(echo $TARGETPLATFORM | sed -e 's/^linux\///g') && \ + curl https://github.com/yandex-cloud/geesefs/releases/latest/download/geesefs-linux-$ARCH -LfSso /work/geesefs + FROM alpine:3.17 LABEL maintainers="Vitaliy Filippov " LABEL description="csi-s3 slim image" @@ -14,7 +24,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-amd64 /usr/bin/geesefs +COPY --from=downloader /work/geesefs /usr/bin/geesefs RUN chmod 755 /usr/bin/geesefs COPY --from=gobuild /build/s3driver /s3driver From 04c551f39cc28b30f75e8d087e01f6cb6d6871da Mon Sep 17 00:00:00 2001 From: motoki317 Date: Sat, 15 Apr 2023 21:55:33 +0900 Subject: [PATCH 3/6] Add build for linux/arm64 --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 10c4558..afb34f3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -44,7 +44,7 @@ jobs: with: context: . push: true - platforms: linux/amd64 + platforms: linux/amd64,linux/arm64 tags: | ${{ env.REGISTRY_NAME }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }} ${{ env.REGISTRY_NAME }}/${{ env.IMAGE_NAME }}:latest From fc0a5720645038a9ee8776ec8ec91a249d9a6862 Mon Sep 17 00:00:00 2001 From: motoki317 Date: Sat, 15 Apr 2023 21:58:39 +0900 Subject: [PATCH 4/6] Bump actions/checkout to v3 --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index afb34f3..88544be 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,7 +20,7 @@ jobs: # GITHUB_REF value: refs/heads/v* run: echo "VERSION=$(echo ${GITHUB_REF:11})" >> $GITHUB_ENV - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up QEMU uses: docker/setup-qemu-action@v2 From 51b939c8fde9b4a9b1725b4c5d22d8fe6fc24a99 Mon Sep 17 00:00:00 2001 From: motoki317 Date: Sat, 22 Apr 2023 12:24:02 +0900 Subject: [PATCH 5/6] use cross compiling --- Dockerfile | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index fe3c070..0566e27 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,21 +1,25 @@ -FROM golang:1.19-alpine as gobuild +# Golang can cross-compile +FROM --platform=$BUILDPLATFORM golang:1.19-alpine as gobuild WORKDIR /build ADD go.mod go.sum /build/ RUN go mod download -x ADD cmd /build/cmd ADD pkg /build/pkg -RUN CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' -o ./s3driver ./cmd/s3driver -FROM alpine:3.17 AS downloader +ARG TARGETOS +ARG TARGETARCH +RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -a -ldflags '-extldflags "-static"' -o ./s3driver ./cmd/s3driver + +FROM --platform=$BUILDPLATFORM alpine:3.17 AS downloader WORKDIR /work RUN apk add --no-cache curl -ARG TARGETPLATFORM -RUN ARCH=$(echo $TARGETPLATFORM | sed -e 's/^linux\///g') && \ - curl https://github.com/yandex-cloud/geesefs/releases/latest/download/geesefs-linux-$ARCH -LfSso /work/geesefs +ARG TARGETOS +ARG TARGETARCH +RUN curl https://github.com/yandex-cloud/geesefs/releases/latest/download/geesefs-$TARGETOS-$TARGETARCH -LfSso /work/geesefs FROM alpine:3.17 LABEL maintainers="Vitaliy Filippov " From 7ffbc6b8b1609aa7ad65e9546f00ea7a62fce2a1 Mon Sep 17 00:00:00 2001 From: motoki317 Date: Sat, 22 Apr 2023 12:24:33 +0900 Subject: [PATCH 6/6] Remove unnecessary QEMU setup --- .github/workflows/release.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 88544be..48ee1eb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,10 +22,6 @@ jobs: - uses: actions/checkout@v3 - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - with: - platforms: all - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v2