From 3baa41a1fbd4c7b6bfcae52e71f6aa076502c310 Mon Sep 17 00:00:00 2001 From: "B. Blechschmidt" Date: Thu, 19 Jun 2025 15:09:06 +0200 Subject: [PATCH] fix: support multi-arch musl builds in Dockerfile --- .github/workflows/publish-docker.yml | 4 +++- Dockerfile | 9 +++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml index d136c67..1288c74 100644 --- a/.github/workflows/publish-docker.yml +++ b/.github/workflows/publish-docker.yml @@ -1,4 +1,4 @@ -name: Create and publish a Docker image +name: Publish Docker Images on: push: @@ -18,8 +18,10 @@ env: # There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu. jobs: build-and-push-image: + name: Build and push Docker image runs-on: ubuntu-latest strategy: + fail-fast: false matrix: os: [ 'scratch', 'ubuntu', 'alpine' ] # Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job. diff --git a/Dockerfile b/Dockerfile index e8e317f..f7aafdc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,8 +21,9 @@ FROM rust:latest AS musl-builder WORKDIR /worker COPY ./ . - RUN rustup target add x86_64-unknown-linux-musl - RUN cargo build --release --target x86_64-unknown-linux-musl + RUN ARCH=$(rustc -vV | sed -nE 's/host:\s*([^-]+).*/\1/p') \ + && rustup target add "$ARCH-unknown-linux-musl" \ + && cargo build --release --target "$ARCH-unknown-linux-musl" RUN mkdir /.etc \ && touch /.etc/resolv.conf \ @@ -35,7 +36,7 @@ FROM rust:latest AS musl-builder #################################################################################################### FROM alpine:latest AS tun2proxy-alpine - COPY --from=musl-builder /worker/target/x86_64-unknown-linux-musl/release/tun2proxy-bin /usr/bin/tun2proxy-bin + COPY --from=musl-builder /worker/target/*/release/tun2proxy-bin /usr/bin/tun2proxy-bin ENTRYPOINT ["/usr/bin/tun2proxy-bin", "--setup"] @@ -55,6 +56,6 @@ FROM scratch AS tun2proxy-scratch COPY --from=musl-builder ./tmp /tmp COPY --from=musl-builder ./etc /etc - COPY --from=musl-builder /worker/target/x86_64-unknown-linux-musl/release/tun2proxy-bin /usr/bin/tun2proxy-bin + COPY --from=musl-builder /worker/target/*/release/tun2proxy-bin /usr/bin/tun2proxy-bin ENTRYPOINT ["/usr/bin/tun2proxy-bin", "--setup"]