Skip to content

Commit

Permalink
🐳 Fix linking building
Browse files Browse the repository at this point in the history
  • Loading branch information
coreequip committed Feb 6, 2025
1 parent 36bf08b commit 4c9907d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
platforms: linux/arm64
tags: |
easybill/spf-check:${{ github.ref_name }}
easybill/spf-check:latest
12 changes: 3 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,27 @@ FROM rust:1.84.1-slim-bookworm AS builder

WORKDIR /usr/src/app

# Install musl-tools for static linking
RUN apt-get update && apt-get install -y musl-tools && rm -rf /var/lib/apt/lists/*

# Set the target to musl for static linking with ARM64
RUN rustup target add aarch64-unknown-linux-musl

# Copy the Cargo files to cache dependencies
COPY Cargo.toml Cargo.lock ./

# Create a dummy main.rs to build dependencies
RUN mkdir src && \
echo 'fn main() { println!("Dummy") }' > src/main.rs && \
cargo build --release --target aarch64-unknown-linux-musl && \
cargo build --release && \
rm src/main.rs

# Now copy the actual source code
COPY src ./src

# Build for release with static linking
RUN touch src/main.rs && \
cargo build --release --target aarch64-unknown-linux-musl
RUSTFLAGS='-C target-feature=+crt-static' cargo build --release

# Runtime stage
FROM scratch

# Copy the build artifact from the build stage
COPY --from=builder /usr/src/app/target/aarch64-unknown-linux-musl/release/spf-check /spf-check
COPY --from=builder /usr/src/app/target/release/spf-check /spf-check

EXPOSE 8080

Expand Down

0 comments on commit 4c9907d

Please sign in to comment.