Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cross-compile cargo plugins #3

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions Dockerfile
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
Loading