Repository: mbrubeck/agate (language: rust)

Issue:
ARM support for container image
Hi!

It looks like the docker container is only available for x86_64 despite there being binaries for aarch64. Is it possible to enable this architecture?

My use case is running this container on an ARM Synology NAS, which doesn't have a very neat way to run Linux binaries directly. FWIW, it does seem to handle the ARM binary fine when I ssh into the box.

cheers!


Discussion / hints:
I'd love to support this.  I’m not a Docker user myself, so it would be a great help if someone else could try adding this to the GitHub Actions workflows, and I will assist however I can.

The existing code is at https://github.com/mbrubeck/agate/blob/master/.github/workflows/release.yml and it depends on:
https://github.com/docker/build-push-action

Fix patch:
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index aee6af6..d42b9fb 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -103,10 +103,17 @@ jobs:
             type=semver,pattern={{major}}.{{minor}}.{{patch}}
             type=semver,pattern={{major}}.{{minor}}
             type=semver,pattern={{major}}
+      - name: Set up QEMU
+        uses: docker/setup-qemu-action@v3
+
+      - name: Set up Docker Buildx
+        uses: docker/setup-buildx-action@v3
+
       - name: Build and push Docker image
         id: push
         uses: docker/build-push-action@v6
         with:
           push: true
+          platforms: linux/amd64,linux/arm64
           tags: ${{ steps.meta.outputs.tags }}
           labels: ${{ steps.meta.outputs.labels }}
diff --git a/Dockerfile b/Dockerfile
index 637d4e7..49eb79c 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -6,7 +6,14 @@ RUN apk --no-cache add libc-dev
 COPY src src
 COPY Cargo.toml .
 COPY Cargo.lock .
-RUN cargo install --target x86_64-unknown-linux-musl --path .
+ARG TARGETARCH
+RUN if [ "$TARGETARCH" = "amd64" ]; then \
+      cargo install --target x86_64-unknown-linux-musl --path . ; \
+    elif [ "$TARGETARCH" = "arm64" ]; then \
+      cargo install --target aarch64-unknown-linux-musl --path . ; \
+    else \
+      echo "The architecture $TARGETARCH isn't unsupported." && exit 1; \
+    fi
 
 FROM docker.io/library/alpine:latest
 COPY --from=builder /usr/local/cargo/bin/agate /usr/bin/agate


Test patch: