Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Build docker arm64 images natively

Damian Legawiec148d18a6c7e1
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 7af40b526d..4c6644ab3a 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -30,13 +30,20 @@ jobs:
run: bundle exec rake gem:release
release-docker:
- name: Release Docker image
+ name: "Docker - Build (${{ matrix.platform }})"
needs: release-gems
if: always() && needs.release-gems.result != 'cancelled'
- runs-on: ubuntu-latest
+ runs-on: ${{ matrix.runner }}
permissions:
contents: read
packages: write
+ strategy:
+ matrix:
+ include:
+ - platform: linux/amd64
+ runner: ubuntu-latest
+ - platform: linux/arm64
+ runner: ubuntu-24.04-arm
env:
REGISTRY: ghcr.io
@@ -45,7 +52,62 @@ jobs:
steps:
- uses: actions/checkout@v4
- - uses: docker/setup-qemu-action@v3
+ - uses: docker/setup-buildx-action@v3
+
+ - uses: docker/login-action@v3
+ with:
+ registry: ${{ env.REGISTRY }}
+ username: ${{ github.actor }}
+ password: ${{ secrets.GITHUB_TOKEN }}
+
+ - uses: docker/metadata-action@v5
+ id: meta
+ with:
+ images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
+
+ - uses: docker/build-push-action@v6
+ id: build
+ with:
+ context: .
+ file: server/Dockerfile.release
+ platforms: ${{ matrix.platform }}
+ labels: ${{ steps.meta.outputs.labels }}
+ cache-from: type=gha,scope=${{ matrix.platform }}
+ cache-to: type=gha,mode=max,scope=${{ matrix.platform }}
+ outputs: type=image,"name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}",push-by-digest=true,name-canonical=true,push=true
+
+ - name: Export digest
+ run: |
+ mkdir -p /tmp/digests
+ digest="${{ steps.build.outputs.digest }}"
+ touch "/tmp/digests/${digest#sha256:}"
+
+ - uses: actions/upload-artifact@v4
+ with:
+ name: digest-${{ matrix.runner }}
+ path: /tmp/digests/*
+ if-no-files-found: error
+ retention-days: 1
+
+ release-docker-manifest:
+ name: "Docker - Publish manifest"
+ needs: release-docker
+ if: always() && needs.release-docker.result == 'success'
+ runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ packages: write
+
+ env:
+ REGISTRY: ghcr.io
+ IMAGE_NAME: spree/spree
+
+ steps:
+ - uses: actions/download-artifact@v4
+ with:
+ path: /tmp/digests
+ pattern: digest-*
+ merge-multiple: true
- uses: docker/setup-buildx-action@v3
@@ -65,13 +127,9 @@ jobs:
type=match,pattern=v(.*),group=1
type=raw,value=latest
- - uses: docker/build-push-action@v6
- with:
- context: .
- file: server/Dockerfile.release
- push: true
- tags: ${{ steps.meta.outputs.tags }}
- labels: ${{ steps.meta.outputs.labels }}
- platforms: linux/amd64,linux/arm64
- cache-from: type=gha
- cache-to: type=gha,mode=max
+ - name: Create and push manifest
+ working-directory: /tmp/digests
+ run: |
+ docker buildx imagetools create \
+ $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< '${{ steps.meta.outputs.json }}') \
+ $(printf '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *)