-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from rucoder/rucoder/fix-native-targets
Set default build target for native builds
- Loading branch information
Showing
1 changed file
with
14 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,14 +24,26 @@ ADD config.toml /usr/local/cargo/ | |
RUN cargo install --root /cargo-cross [email protected] [email protected] | ||
|
||
|
||
FROM rust:${RUST_VERSION}-alpine3.20 | ||
FROM rust:${RUST_VERSION}-alpine3.20 AS tools-target-base | ||
ENV TARGETS="x86_64-unknown-linux-musl aarch64-unknown-linux-musl x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu riscv64gc-unknown-linux-gnu" | ||
RUN rustup target add ${TARGETS} | ||
|
||
# needed for cargo-chef and cargo-sbom, as well as many other compilations | ||
RUN apk add musl-dev linux-headers make clang mold | ||
RUN apk add musl-dev linux-headers make clang mold python3 | ||
|
||
# copy the cargo plugins from the tools stage | ||
COPY --from=tools /cargo-cross /usr/local/cargo | ||
# we define target specific rustc flags for cross-compilation | ||
ADD config.toml /usr/local/cargo/ | ||
|
||
FROM tools-target-base AS tools-target-amd64 | ||
ENV CARGO_BUILD_TARGET="x86_64-unknown-linux-musl" | ||
|
||
FROM tools-target-base AS tools-target-arm64 | ||
ENV CARGO_BUILD_TARGET="aarch64-unknown-linux-musl" | ||
|
||
FROM tools-target-base AS tools-target-riscv64 | ||
ENV CARGO_BUILD_TARGET="riscv64gc-unknown-linux-gnu" | ||
|
||
FROM tools-target-$TARGETARCH AS tools-target | ||
RUN echo "Cargo target: $CARGO_BUILD_TARGET" |