Bläddra i källkod

Publish a single multi-arch Docker image

Build amd64 and arm64 natively (no emulation), push each by
digest, then merge them into one multi-arch manifest so
`zedeus/nitter:latest` and `:<sha>` resolve to the right image
on any CPU. Replaces the separate `latest-arm64` tag, which is
no longer needed. Update the README notes accordingly.
Zed 3 månader sedan
förälder
incheckning
f629507537
2 ändrade filer med 76 tillägg och 24 borttagningar
  1. 75 21
      .github/workflows/build-docker.yml
  2. 1 3
      README.md

+ 75 - 21
.github/workflows/build-docker.yml

@@ -7,55 +7,109 @@ on:
     branches:
     branches:
       - master
       - master
 
 
+env:
+  IMAGE: zedeus/nitter
+
 jobs:
 jobs:
   tests:
   tests:
     uses: ./.github/workflows/run-tests.yml
     uses: ./.github/workflows/run-tests.yml
     secrets: inherit
     secrets: inherit
 
 
-  build-docker-amd64:
+  # Build each architecture natively (no emulation) and push by digest only.
+  # The digests are stitched into a single multi-arch tag by the merge job.
+  build:
     needs: [tests]
     needs: [tests]
-    runs-on: ubuntu-24.04
+    strategy:
+      fail-fast: false
+      matrix:
+        include:
+          - runner: ubuntu-24.04
+            platform: linux/amd64
+          - runner: ubuntu-24.04-arm
+            platform: linux/arm64
+    runs-on: ${{ matrix.runner }}
     steps:
     steps:
+      - name: Prepare platform name
+        run: echo "PLATFORM_PAIR=${platform//\//-}" >> "$GITHUB_ENV"
+        env:
+          platform: ${{ matrix.platform }}
+
       - uses: actions/checkout@v6
       - uses: actions/checkout@v6
+
       - name: Set up Docker Buildx
       - name: Set up Docker Buildx
-        id: buildx
         uses: docker/setup-buildx-action@v3
         uses: docker/setup-buildx-action@v3
         with:
         with:
           version: latest
           version: latest
+
       - name: Login to DockerHub
       - name: Login to DockerHub
         uses: docker/login-action@v3
         uses: docker/login-action@v3
         with:
         with:
           username: ${{ secrets.DOCKER_USERNAME }}
           username: ${{ secrets.DOCKER_USERNAME }}
           password: ${{ secrets.DOCKER_PASSWORD }}
           password: ${{ secrets.DOCKER_PASSWORD }}
-      - name: Build and push AMD64 Docker image
-        uses: docker/build-push-action@v3
+
+      - name: Build and push by digest
+        id: build
+        uses: docker/build-push-action@v6
         with:
         with:
           context: .
           context: .
           file: ./Dockerfile
           file: ./Dockerfile
-          platforms: linux/amd64
-          push: true
-          tags: zedeus/nitter:latest,zedeus/nitter:${{ github.sha }}
+          platforms: ${{ matrix.platform }}
+          outputs: type=image,name=${{ env.IMAGE }},push-by-digest=true,name-canonical=true,push=true
+          # Attestations turn a single-platform push into a manifest index, which
+          # breaks push-by-digest + the imagetools merge below. Disable them.
+          provenance: false
+          sbom: false
 
 
-  build-docker-arm64:
-    needs: [tests]
-    runs-on: ubuntu-24.04-arm
+      - 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
+
+  # Combine the per-arch digests into one multi-arch manifest so that
+  # `docker pull zedeus/nitter:latest` serves the right image on any CPU.
+  merge:
+    needs: [build]
+    runs-on: ubuntu-24.04
     steps:
     steps:
-      - uses: actions/checkout@v6
+      - name: Download digests
+        uses: actions/download-artifact@v4
+        with:
+          path: ${{ runner.temp }}/digests
+          pattern: digests-*
+          merge-multiple: true
+
       - name: Set up Docker Buildx
       - name: Set up Docker Buildx
-        id: buildx
         uses: docker/setup-buildx-action@v3
         uses: docker/setup-buildx-action@v3
         with:
         with:
           version: latest
           version: latest
+
       - name: Login to DockerHub
       - name: Login to DockerHub
         uses: docker/login-action@v3
         uses: docker/login-action@v3
         with:
         with:
           username: ${{ secrets.DOCKER_USERNAME }}
           username: ${{ secrets.DOCKER_USERNAME }}
           password: ${{ secrets.DOCKER_PASSWORD }}
           password: ${{ secrets.DOCKER_PASSWORD }}
-      - name: Build and push ARM64 Docker image
-        uses: docker/build-push-action@v3
-        with:
-          context: .
-          file: ./Dockerfile
-          platforms: linux/arm64
-          push: true
-          tags: zedeus/nitter:latest-arm64,zedeus/nitter:${{ github.sha }}-arm64
+
+      - name: Create manifest list and push
+        working-directory: ${{ runner.temp }}/digests
+        run: |
+          # latest-arm64 is a backward-compat alias of the (now multi-arch)
+          # latest tag, for users still pinned to the old ARM64-only image.
+          # word splitting is intentional: one image ref arg per digest file
+          # shellcheck disable=SC2046
+          docker buildx imagetools create \
+            -t ${{ env.IMAGE }}:latest \
+            -t ${{ env.IMAGE }}:latest-arm64 \
+            -t ${{ env.IMAGE }}:${{ github.sha }} \
+            $(printf '${{ env.IMAGE }}@sha256:%s ' *)
+
+      - name: Inspect image
+        run: docker buildx imagetools inspect ${{ env.IMAGE }}:${{ github.sha }}

+ 1 - 3
README.md

@@ -123,7 +123,7 @@ performance reasons.
 
 
 Page for the Docker image: https://hub.docker.com/r/zedeus/nitter
 Page for the Docker image: https://hub.docker.com/r/zedeus/nitter
 
 
-#### NOTE: For ARM64 support, please use the separate ARM64 docker image: [`zedeus/nitter:latest-arm64`](https://hub.docker.com/r/zedeus/nitter/tags).
+#### NOTE: The published image is multi-arch — `zedeus/nitter:latest` runs natively on both `amd64` and `arm64`.
 
 
 To run Nitter with Docker, you'll need to install and run Redis separately
 To run Nitter with Docker, you'll need to install and run Redis separately
 before you can run the container. See below for how to also run Redis using
 before you can run the container. See below for how to also run Redis using
@@ -147,8 +147,6 @@ docker build -t nitter:latest .
 docker run -v $(pwd)/nitter.conf:/src/nitter.conf -d --network host nitter:latest
 docker run -v $(pwd)/nitter.conf:/src/nitter.conf -d --network host nitter:latest
 ```
 ```
 
 
-Note: For ARM64, use this Dockerfile: [`Dockerfile.arm64`](https://github.com/zedeus/nitter/blob/master/Dockerfile.arm64).
-
 A prebuilt Docker image is provided as well:
 A prebuilt Docker image is provided as well:
 
 
 ```bash
 ```bash