Skip to content

Commit e2d300a

Browse files
authored
Merge pull request #10 from rucoder/rucoder/fix-native-targets
Set default build target for native builds
2 parents e3bbfee + 2b63002 commit e2d300a

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

Dockerfile

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,26 @@ ADD config.toml /usr/local/cargo/
2424
RUN cargo install --root /cargo-cross [email protected] [email protected]
2525

2626

27-
FROM rust:${RUST_VERSION}-alpine3.20
27+
FROM rust:${RUST_VERSION}-alpine3.20 AS tools-target-base
2828
ENV TARGETS="x86_64-unknown-linux-musl aarch64-unknown-linux-musl x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu riscv64gc-unknown-linux-gnu"
2929
RUN rustup target add ${TARGETS}
3030

3131
# needed for cargo-chef and cargo-sbom, as well as many other compilations
32-
RUN apk add musl-dev linux-headers make clang mold
32+
RUN apk add musl-dev linux-headers make clang mold python3
3333

3434
# copy the cargo plugins from the tools stage
3535
COPY --from=tools /cargo-cross /usr/local/cargo
3636
# we define target specific rustc flags for cross-compilation
3737
ADD config.toml /usr/local/cargo/
38+
39+
FROM tools-target-base AS tools-target-amd64
40+
ENV CARGO_BUILD_TARGET="x86_64-unknown-linux-musl"
41+
42+
FROM tools-target-base AS tools-target-arm64
43+
ENV CARGO_BUILD_TARGET="aarch64-unknown-linux-musl"
44+
45+
FROM tools-target-base AS tools-target-riscv64
46+
ENV CARGO_BUILD_TARGET="riscv64gc-unknown-linux-gnu"
47+
48+
FROM tools-target-$TARGETARCH AS tools-target
49+
RUN echo "Cargo target: $CARGO_BUILD_TARGET"

0 commit comments

Comments
 (0)