-
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.
Signed-off-by: Avi Deitcher <[email protected]>
- Loading branch information
Showing
1 changed file
with
19 additions
and
4 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 |
---|---|---|
@@ -1,8 +1,23 @@ | ||
ARG RUST_VERSION=1.80.1 | ||
FROM rust:${RUST_VERSION}-alpine3.20 | ||
ENV TARGETS="x86_64-unknown-linux-musl aarch64-unknown-linux-musl x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu riscv64gc-unknown-linux-gnu" | ||
|
||
FROM --platform=$BUILDPLATFORM tonistiigi/xx AS xx | ||
|
||
FROM --platform=$BUILDPLATFORM rust:${RUST_VERSION}-alpine3.20 AS builder | ||
ARG TARGETARCH | ||
ARG TARGETOS | ||
COPY --from=xx / / | ||
RUN echo $(xx-info march)-unknown-$(xx-info os)-musl > /etc/rustc_target | ||
|
||
RUN rustup target add $(cat /etc/rustc_target) | ||
# needed for cargo-chef and cargo-sbom | ||
RUN apk add musl-dev linux-headers make | ||
RUN cargo install --target=$(cat /etc/rustc_target) [email protected] [email protected] | ||
|
||
FROM rust:${RUST_VERSION}-alpine3.20 AS toolchain | ||
ARG 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 | ||
# needed for downstream compilations | ||
RUN apk add musl-dev linux-headers make | ||
RUN cargo install [email protected] [email protected] | ||
COPY --from=builder /usr/local/cargo/bin/cargo-chef /usr/local/cargo/bin | ||
COPY --from=builder /usr/local/cargo/bin/cargo-sbom /usr/local/cargo/bin |