This is an automated email from the ASF dual-hosted git repository.

vishesh pushed a commit to branch main
in repository 
https://gitbox.apache.org/repos/asf/cloudstack-kubernetes-provider.git


The following commit(s) were added to refs/heads/main by this push:
     new 90adbee4 Add support for arm64 image (#81)
90adbee4 is described below

commit 90adbee47540dbc10fea8642d0e1ef0c84a297ac
Author: Vishesh <[email protected]>
AuthorDate: Tue Nov 25 15:20:20 2025 +0100

    Add support for arm64 image (#81)
---
 .github/workflows/build-docker-image.yml | 50 ++++++++++++++++++++++++--------
 Dockerfile                               |  7 +++--
 2 files changed, 43 insertions(+), 14 deletions(-)

diff --git a/.github/workflows/build-docker-image.yml 
b/.github/workflows/build-docker-image.yml
index 28c1f689..67023b07 100644
--- a/.github/workflows/build-docker-image.yml
+++ b/.github/workflows/build-docker-image.yml
@@ -34,16 +34,9 @@ concurrency:
 
 jobs:
   build:
-    if: github.repository == 'apache/cloudstack-kubernetes-provider' && 
(github.event_name != 'pull_request' || 
github.event.pull_request.head.repo.full_name == github.repository)
+    if: github.repository == 'apache/cloudstack-kubernetes-provider'
     runs-on: ubuntu-22.04
     steps:
-      - name: Login to Docker Registry
-        uses: docker/login-action@v3
-        with:
-          registry: ${{ secrets.DOCKER_REGISTRY }}
-          username: ${{ secrets.DOCKERHUB_USER }}
-          password: ${{ secrets.DOCKERHUB_TOKEN }}
-
       - name: Set Docker repository name
         run: echo "DOCKER_REPOSITORY=apache" >> $GITHUB_ENV
 
@@ -57,8 +50,41 @@ jobs:
       - name: Set Docker image FULL TAG
         run: echo "FULL_TAG=$(if [ "${{ secrets.DOCKER_REGISTRY }}" = "" 
];then echo ${DOCKER_REPOSITORY}/cloudstack-kubernetes-provider:${TAG};else 
echo ${{ secrets.DOCKER_REGISTRY 
}}/${DOCKER_REPOSITORY}/cloudstack-kubernetes-provider:${TAG};fi)" >> 
$GITHUB_ENV
 
-      - name: Build the Docker image for cloudstack-kubernetes-provider
-        run: docker build . --file Dockerfile --tag ${FULL_TAG}
+      - name: Check if should push
+        id: should_push
+        run: |
+          if [ "${{ github.event_name }}" != "pull_request" ] || [ "${{ 
github.event.pull_request.head.repo.full_name }}" = "${{ github.repository }}" 
]; then
+            echo "should_push=true" >> $GITHUB_OUTPUT
+          else
+            echo "should_push=false" >> $GITHUB_OUTPUT
+          fi
 
-      - name: Push Docker image to Docker Registry
-        run: docker push ${FULL_TAG}
+      - name: Set up Docker Buildx
+        uses: docker/setup-buildx-action@v3
+
+      - name: Login to Docker Registry
+        if: steps.should_push.outputs.should_push == 'true'
+        uses: docker/login-action@v3
+        with:
+          registry: ${{ secrets.DOCKER_REGISTRY }}
+          username: ${{ secrets.DOCKERHUB_USER }}
+          password: ${{ secrets.DOCKERHUB_TOKEN }}
+
+      - name: Set cache configuration
+        id: cache_config
+        run: |
+          if [ "${{ steps.should_push.outputs.should_push }}" = "true" ]; then
+            echo "cache_from=type=registry,ref=${FULL_TAG}-cache" >> 
$GITHUB_OUTPUT
+            echo "cache_to=type=registry,ref=${FULL_TAG}-cache,mode=max" >> 
$GITHUB_OUTPUT
+          fi
+
+      - name: Build and push Docker image for cloudstack-kubernetes-provider 
(multi-arch)
+        uses: docker/build-push-action@v6
+        with:
+          context: .
+          file: ./Dockerfile
+          platforms: linux/amd64,linux/arm64
+          push: ${{ steps.should_push.outputs.should_push == 'true' }}
+          tags: ${{ env.FULL_TAG }}
+          cache-from: ${{ steps.cache_config.outputs.cache_from }}
+          cache-to: ${{ steps.cache_config.outputs.cache_to }}
diff --git a/Dockerfile b/Dockerfile
index b2dd52de..ba02c0dc 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -15,10 +15,13 @@
 # specific language governing permissions and limitations
 # under the License.
 
-FROM golang:1.21 as builder
+FROM --platform=$BUILDPLATFORM golang:1.23 AS builder
+ARG BUILDPLATFORM
+ARG TARGETOS
+ARG TARGETARCH
 COPY . /go/src/github.com/apache/cloudstack-kubernetes-provider
 WORKDIR /go/src/github.com/apache/cloudstack-kubernetes-provider
-RUN make clean && CGO_ENABLED=0 GOOS=linux make
+RUN make clean && CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} make
 
 FROM gcr.io/distroless/static:nonroot
 COPY --from=builder 
/go/src/github.com/apache/cloudstack-kubernetes-provider/cloudstack-ccm 
/app/cloudstack-ccm

Reply via email to