From a8360b2492c452666267d03f0f6ad3789757f534 Mon Sep 17 00:00:00 2001 From: Reza Behzadan Date: Fri, 3 Jan 2025 11:52:26 -0500 Subject: [PATCH] Add Multi-Arch build workflow for github --- .github/workflows/build-and-push.yaml | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build-and-push.yaml b/.github/workflows/build-and-push.yaml index 83010a1..a3b4195 100644 --- a/.github/workflows/build-and-push.yaml +++ b/.github/workflows/build-and-push.yaml @@ -1,4 +1,4 @@ -name: Build and Publish Docker Image +name: Build and Publish Docker Image (Multi-Arch) on: release: @@ -11,13 +11,15 @@ env: jobs: build-and-publish: runs-on: ubuntu-latest - steps: - - name: Checkout the code + - name: Checkout code uses: actions/checkout@v4 - - name: Build Docker image - run: docker build -t ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} . + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - name: Login to Docker Hub uses: docker/login-action@v2 @@ -25,8 +27,13 @@ jobs: username: ${{ secrets.DOCKER_HUB_USERNAME }} password: ${{ secrets.DOCKER_HUB_PASSWORD }} - - name: Push Docker image to Docker Hub - run: | - docker push ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} - docker tag ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} ${{ env.IMAGE_NAME }}:latest - docker push ${{ env.IMAGE_NAME }}:latest + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: | + ${{ env.IMAGE_NAME }}:latest + ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} +