Skip to content

Node.js based forum software built for the modern web

ci: use native arm runners for building docker images (#13627)

Jakub Bliźniuk931b7345e456
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
index 742f443f9c..a1a7cd9871 100644
--- a/.github/workflows/docker.yml
+++ b/.github/workflows/docker.yml
@@ -16,15 +16,29 @@ permissions:
packages: write
jobs:
- release:
- runs-on: ubuntu-latest
+ build:
+ strategy:
+ matrix:
+ include:
+ - os: ubuntu-latest
+ platforms: linux/amd64
+ required: true
+ - os: ubuntu-24.04-arm
+ platforms: linux/arm64
+ required: true
+ - os: ubuntu-24.04-arm
+ platforms: linux/arm/v7
+ required: false
+ continue-on-error: ${{ !matrix.required }}
+ runs-on: ${{ matrix.os }}
steps:
-
+ - name: Prepare
+ run: |
+ platform=${{ matrix.platforms }}
+ echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
+ echo "IMAGE=ghcr.io/${GITHUB_REPOSITORY@L}" >> $GITHUB_ENV
- uses: actions/checkout@v4
- - name: Set up QEMU
- uses: docker/setup-qemu-action@v3
-
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
@@ -34,39 +48,87 @@ jobs:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
-
- - name: Get current date in NST
- run: echo "CURRENT_DATE_NST=$(date +'%Y%m%d-%H%M%S' -d '-3 hours -30 minutes')" >> $GITHUB_ENV
-
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
- images: ghcr.io/${{ github.repository }}
- tags: |
- type=semver,pattern={{version}}
- type=semver,pattern={{major}}.{{minor}}
- type=semver,pattern={{major}}.x
- type=raw,value=latest,enable={{is_default_branch}}
- type=ref,event=branch,enable=${{ github.event.repository.default_branch != github.ref }}
- type=raw,value=${{ env.CURRENT_DATE_NST }}
- flavor: |
- latest=true
-
+ images: ${{ env.IMAGE }}
+
- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v4
with:
path: var-cache-node-modules
key: var-cache-node-modules-${{ hashFiles('Dockerfile', 'install/package.json') }}
-
+
- name: Build and push Docker images
+ id: build
uses: docker/build-push-action@v6
with:
cache-from: type=gha
cache-to: type=gha,mode=min
context: .
file: ./Dockerfile
- platforms: linux/amd64,linux/arm64,linux/arm/v7
- push: true
- tags: ${{ steps.meta.outputs.tags }}
+ platforms: ${{ matrix.platforms }}
+ labels: ${{ steps.meta.outputs.labels }}
+ tags: ${{ env.IMAGE }}
+ outputs: type=image,push-by-digest=true,name-canonical=true,push=true
+ - name: Export digest
+ run: |
+ mkdir -p ${{ runner.temp }}/digests
+ digest="${{ steps.build.outputs.digest }}"
+ touch "${{ runner.temp }}/digests/${digest#sha256:}"
+
+ - name: Upload digest
+ uses: actions/upload-artifact@v4
+ with:
+ name: digests-${{ env.PLATFORM_PAIR }}
+ path: ${{ runner.temp }}/digests/*
+ if-no-files-found: error
+ retention-days: 1
+ merge:
+ runs-on: ubuntu-latest
+ needs:
+ - build
+ steps:
+ - name: Prepare
+ run: |
+ echo "IMAGE=ghcr.io/${GITHUB_REPOSITORY@L}" >> $GITHUB_ENV
+ echo "CURRENT_DATE_NST=$(date +'%Y%m%d-%H%M%S' -d '-3 hours -30 minutes')" >> $GITHUB_ENV
+ - name: Download digests
+ uses: actions/download-artifact@v4
+ with:
+ path: ${{ runner.temp }}/digests
+ pattern: digests-*
+ merge-multiple: true
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v3
+
+ - name: Login to GitHub Container Registry
+ uses: docker/login-action@v3
+ with:
+ registry: ghcr.io
+ username: ${{ github.repository_owner }}
+ password: ${{ secrets.GITHUB_TOKEN }}
+ - name: Docker meta
+ id: meta
+ uses: docker/metadata-action@v5
+ with:
+ images: ${{ env.IMAGE }}
+ tags: |
+ type=semver,pattern={{version}}
+ type=semver,pattern={{major}}.{{minor}}
+ type=semver,pattern={{major}}.x
+ type=raw,value=latest,enable={{is_default_branch}}
+ type=ref,event=branch,enable=${{ github.event.repository.default_branch != github.ref }}
+ type=raw,value=${{ env.CURRENT_DATE_NST }}
+ flavor: |
+ latest=true
+ - name: Create manifest list and push
+ working-directory: ${{ runner.temp }}/digests
+ run: |
+ docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
+ $(printf '${{ env.IMAGE }}@sha256:%s ' *)
+ - name: Inspect image
+ run: |
+ docker buildx imagetools inspect ${{ env.IMAGE }}:${{ steps.meta.outputs.version }}
\ No newline at end of file