Skip to content

Commit

Permalink
Set default build target for native builds
Browse files Browse the repository at this point in the history
Signed-off-by: Mikhail Malyshev <[email protected]>
  • Loading branch information
rucoder committed Aug 23, 2024
1 parent e3bbfee commit 6e467b4
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ 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
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}

Expand All @@ -35,3 +35,15 @@ RUN apk add musl-dev linux-headers make clang mold
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 AS tools-target-amd64
ENV CARGO_BUILD_TARGET="x86_64-unknown-linux-musl"

FROM tools-target AS tools-target-arm64
ENV CARGO_BUILD_TARGET="aarch64-unknown-linux-musl"

FROM tools-target AS tools-target-riscv64
ENV CARGO_BUILD_TARGET="riscv64gc-unknown-linux-gnu"

FROM tools-target-$TARGETARCH AS tools-trget
RUN echo "Cargo target: $CARGO_BUILD_TARGET"

0 comments on commit 6e467b4

Please sign in to comment.