Skip to content

Commit ebe818a

Browse files
haasonsaasclaude
andcommitted
fix: resolve Docker multi-arch and macOS ARM build issues
- Fix Docker to build for native architecture instead of forcing x86_64 - Add macOS cross-compilation environment setup for ARM64 builds - Skip strip command for cross-compiled ARM64 binaries - Add file existence check before creating checksums - Remove hardcoded musl target from Dockerfile These changes should fix: 1. Docker multi-architecture builds (ARM64 and AMD64) 2. macOS ARM64 cross-compilation from x86_64 runners 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent dd43bda commit ebe818a

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

.github/workflows/release.yml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,19 +117,36 @@ jobs:
117117
sudo apt-get update
118118
sudo apt-get install -y musl-tools
119119
120+
- name: Set up macOS cross-compilation
121+
if: matrix.os == 'macos-latest' && matrix.target == 'aarch64-apple-darwin'
122+
run: |
123+
echo "SDKROOT=$(xcrun -sdk macosx --show-sdk-path)" >> $GITHUB_ENV
124+
echo "MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx --show-sdk-platform-version)" >> $GITHUB_ENV
125+
120126
- name: Build
121127
run: cargo build --release --target ${{ matrix.target }}
122128

123129
- name: Strip binary (Linux and macOS)
124-
if: matrix.os != 'windows-latest'
130+
if: matrix.os != 'windows-latest' && matrix.target != 'aarch64-apple-darwin'
125131
run: |
126132
strip target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
127133
134+
- name: Strip binary (macOS ARM64)
135+
if: matrix.target == 'aarch64-apple-darwin'
136+
run: |
137+
# Skip stripping for cross-compiled ARM64 binary or use lipo if needed
138+
echo "Skipping strip for cross-compiled ARM64 binary"
139+
128140
- name: Create checksum (Unix)
129141
if: matrix.os != 'windows-latest'
130142
run: |
131143
cd target/${{ matrix.target }}/release/
132-
sha256sum ${{ matrix.artifact_name }} > ${{ matrix.asset_name }}.sha256
144+
if [ -f "${{ matrix.artifact_name }}" ]; then
145+
sha256sum ${{ matrix.artifact_name }} > ${{ matrix.asset_name }}.sha256
146+
else
147+
echo "Binary not found, build may have failed"
148+
exit 1
149+
fi
133150
134151
- name: Create checksum (Windows)
135152
if: matrix.os == 'windows-latest'

Dockerfile

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,20 @@ FROM rust:alpine AS builder
33

44
RUN apk add --no-cache musl-dev
55

6-
# Install the musl target
7-
RUN rustup target add x86_64-unknown-linux-musl
8-
96
WORKDIR /app
107
COPY Cargo.toml Cargo.lock ./
118
COPY src ./src
129

13-
RUN cargo build --release --target x86_64-unknown-linux-musl
14-
RUN strip target/x86_64-unknown-linux-musl/release/diffscope
10+
# Build for the native architecture
11+
RUN cargo build --release
12+
RUN strip target/release/diffscope
1513

1614
# Runtime stage
1715
FROM alpine:3.19
1816

1917
RUN apk add --no-cache ca-certificates
2018

21-
COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/diffscope /usr/local/bin/diffscope
19+
COPY --from=builder /app/target/release/diffscope /usr/local/bin/diffscope
2220

2321
ENTRYPOINT ["diffscope"]
2422
CMD ["--help"]

0 commit comments

Comments
 (0)