From 3ac69a763595e144f32b26ea06077f78b70ac1bf Mon Sep 17 00:00:00 2001 From: Irene A <121013355+Jossey28@users.noreply.github.com> Date: Fri, 12 Jun 2026 21:57:47 -0500 Subject: [PATCH 1/3] Testing multi-arch deployment --- .github/workflows/docker.yml | 107 ++++++++++++++++++++++++++++------- 1 file changed, 88 insertions(+), 19 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index e41af7fb..33b71c9c 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -16,22 +16,11 @@ env: REGISTRY: ghcr.io jobs: - build-and-push: + prepare-tags-and-names: runs-on: ubuntu-latest - strategy: - matrix: - service: - - name: frontend - image: librislog - dockerfile: ./frontend/Dockerfile - context: ./frontend - - name: backend - image: librislog-api - dockerfile: ./backend/Dockerfile - context: ./backend + permissions: contents: read - packages: write steps: - name: Checkout repository @@ -59,6 +48,46 @@ jobs: SANITIZED="$(echo "$SANITIZED" | sed 's/^[^a-zA-Z0-9_]\+//')" echo "sanitized_tag=${SANITIZED:0:128}" >> "$GITHUB_OUTPUT" + outputs: + version: ${{ steps.version.outputs.version }} + sha_short: ${{ steps.version.outputs.sha_short }} + sanitized_tag: ${{ steps.sanitize.outputs.sanitized_tag }} + + build-and-push: + runs-on: ${{ matrix.runner }} + needs: prepare-tags-and-names + strategy: + fail-fast: false + matrix: + service: + - name: frontend + image: librislog + dockerfile: ./frontend/Dockerfile + context: ./frontend + - name: backend + image: librislog-api + dockerfile: ./backend/Dockerfile + context: ./backend + + arch: [amd64, arm64] + + include: + - arch: amd64 + runner: ubuntu-latest + - arch: arm64 + runner: ubuntu-24.04-arm + + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v6 + with: + fetch-depth: 0 + ref: ${{ github.event.inputs.branch || github.ref }} + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v4 @@ -73,13 +102,13 @@ jobs: id: tags run: | IMAGE="${{ env.REGISTRY }}/${{ github.repository }}/${{ matrix.service.image }}" - SHA_SHORT="${{ steps.version.outputs.sha_short }}" + SHA_SHORT="${{ needs.prepare-tags-and-names.outputs.sha_short }}" if [ "${{ github.event_name }}" = "release" ]; then - SANITIZED="${{ steps.sanitize.outputs.sanitized_tag }}" - TAGS="${IMAGE}:${SANITIZED},${IMAGE}:latest" + SANITIZED="${{ needs.prepare-tags-and-names.outputs.sanitized_tag }}" + TAGS="${IMAGE}:${SANITIZED}-${{ matrix.arch }},${IMAGE}:latest-${{ matrix.arch }}" else - TAGS="${IMAGE}:develop,${IMAGE}:${SHA_SHORT}" + TAGS="${IMAGE}:develop-${{ matrix.arch }},${IMAGE}:${SHA_SHORT}-${{ matrix.arch }}" fi echo "tags=${TAGS}" >> "$GITHUB_OUTPUT" @@ -90,11 +119,51 @@ jobs: context: ${{ matrix.service.context }} file: ${{ matrix.service.dockerfile }} push: true - platforms: linux/amd64 + platforms: linux/${{ matrix.arch }} tags: ${{ steps.tags.outputs.tags }} build-args: | - APP_VERSION=${{ steps.version.outputs.version }} + APP_VERSION=${{ needs.prepare-tags-and-names.outputs.version }} GIT_SHA=${{ github.sha }} ${{ matrix.service.name == 'frontend' && 'PUBLIC_DEFAULT_LOCALE=en' || '' }} cache-from: type=gha cache-to: type=gha,mode=max + + create-manifest: + needs: [prepare-tags-and-names, build-and-push] + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + service: + - name: frontend + image: librislog + - name: backend + image: librislog-api + + permissions: + packages: write + + steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v4 + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v4 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Create multi-arch manifest + run: | + IMAGE="${{ env.REGISTRY }}/${{ github.repository }}/${{ matrix.service.image }}" + SHA_SHORT="${{ needs.prepare-tags-and-names.outputs.sha_short }}" + + if [ "${{ github.event_name }}" = "release" ]; then + SANITIZED="${{ needs.prepare-tags-and-names.outputs.sanitized_tag }}" + docker buildx imagetools create -t "${IMAGE}:${SANITIZED}" "${IMAGE}:${SANITIZED}-amd64" "${IMAGE}:${SANITIZED}-arm64" + docker buildx imagetools create -t "${IMAGE}:latest" "${IMAGE}:latest-amd64" "${IMAGE}:latest-arm64" + else + docker buildx imagetools create -t "${IMAGE}:develop" "${IMAGE}:develop-amd64" "${IMAGE}:develop-arm64" + docker buildx imagetools create -t "${IMAGE}:${SHA_SHORT}" "${IMAGE}:${SHA_SHORT}-amd64" "${IMAGE}:${SHA_SHORT}-arm64" + fi From d1c380c9eaa6f51caeaa4aa7f5baef187a95a492 Mon Sep 17 00:00:00 2001 From: Irene A <121013355+Jossey28@users.noreply.github.com> Date: Fri, 12 Jun 2026 22:04:49 -0500 Subject: [PATCH 2/3] Name normalization needed because my username contains caps --- .github/workflows/docker.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 33b71c9c..e3987be2 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -48,10 +48,18 @@ jobs: SANITIZED="$(echo "$SANITIZED" | sed 's/^[^a-zA-Z0-9_]\+//')" echo "sanitized_tag=${SANITIZED:0:128}" >> "$GITHUB_OUTPUT" + - name: Normalize repository name + id: repo + uses: actions/github-script@v7 + with: + result-encoding: string + script: return context.repo.repository.toLowerCase() + outputs: version: ${{ steps.version.outputs.version }} sha_short: ${{ steps.version.outputs.sha_short }} sanitized_tag: ${{ steps.sanitize.outputs.sanitized_tag }} + repository: ${{ steps.repo.outputs.result }} build-and-push: runs-on: ${{ matrix.runner }} @@ -101,7 +109,7 @@ jobs: - name: Generate image tags id: tags run: | - IMAGE="${{ env.REGISTRY }}/${{ github.repository }}/${{ matrix.service.image }}" + IMAGE="${{ env.REGISTRY }}/${{ needs.prepare-tags-and-names.outputs.repository }}/${{ matrix.service.image }}" SHA_SHORT="${{ needs.prepare-tags-and-names.outputs.sha_short }}" if [ "${{ github.event_name }}" = "release" ]; then @@ -156,7 +164,7 @@ jobs: - name: Create multi-arch manifest run: | - IMAGE="${{ env.REGISTRY }}/${{ github.repository }}/${{ matrix.service.image }}" + IMAGE="${{ env.REGISTRY }}/${{ needs.prepare-tags-and-names.outputs.repository }}/${{ matrix.service.image }}" SHA_SHORT="${{ needs.prepare-tags-and-names.outputs.sha_short }}" if [ "${{ github.event_name }}" = "release" ]; then From d65162766c1c70474fc0d5129b21b3c16c0eddf8 Mon Sep 17 00:00:00 2001 From: Irene A <121013355+Jossey28@users.noreply.github.com> Date: Fri, 12 Jun 2026 22:13:07 -0500 Subject: [PATCH 3/3] Fixed minor mistake in repository name normilization --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index e3987be2..083f2e9b 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -53,7 +53,7 @@ jobs: uses: actions/github-script@v7 with: result-encoding: string - script: return context.repo.repository.toLowerCase() + script: return `${context.repo.owner}/${context.repo.repo}`.toLowerCase() outputs: version: ${{ steps.version.outputs.version }}