-
Notifications
You must be signed in to change notification settings - Fork 2
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 #471 from MaterializeInc/cross_compile
Cross compile
- Loading branch information
Showing
3 changed files
with
34 additions
and
11 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,26 +1,39 @@ | ||
FROM rust:1.74.0-slim-bookworm AS chef | ||
FROM --platform=$BUILDPLATFORM rust:1.74.0-slim-bookworm AS chef | ||
RUN cargo install --locked cargo-chef | ||
ARG TARGETARCH | ||
RUN echo -n "$TARGETARCH" | sed 's#amd64#x86_64#;s#arm64#aarch64#' > /cargo_arch | ||
RUN rustup target add x86_64-unknown-linux-gnu | ||
RUN rustup target add aarch64-unknown-linux-gnu | ||
WORKDIR /workdir | ||
|
||
FROM chef AS planner | ||
FROM --platform=$BUILDPLATFORM chef AS planner | ||
COPY . . | ||
RUN cargo chef prepare --recipe-path recipe.json | ||
|
||
FROM chef AS builder | ||
FROM --platform=$BUILDPLATFORM chef AS builder | ||
RUN apt-get update \ | ||
&& apt-get -qy install pkg-config libssl-dev cmake g++ \ | ||
&& apt-get -qy install pkg-config libssl-dev cmake g++ gcc-x86-64-linux-gnu gcc-aarch64-linux-gnu perl \ | ||
&& apt-get clean | ||
WORKDIR /workdir | ||
COPY --from=planner /workdir/recipe.json recipe.json | ||
ARG CARGO_RELEASE=--release | ||
ARG CARGO_FEATURES=--no-default-features | ||
RUN cargo chef cook $CARGO_RELEASE $CARGO_FEATURES --recipe-path recipe.json | ||
RUN export CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=x86_64-linux-gnu-gcc; \ | ||
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc; \ | ||
cargo chef cook \ | ||
$CARGO_RELEASE \ | ||
$CARGO_FEATURES \ | ||
--recipe-path recipe.json \ | ||
--target "$(cat /cargo_arch)-unknown-linux-gnu" | ||
COPY . . | ||
RUN cargo build $CARGO_RELEASE $CARGO_FEATURES | ||
RUN export CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=x86_64-linux-gnu-gcc; \ | ||
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc; \ | ||
cargo build $CARGO_RELEASE $CARGO_FEATURES \ | ||
--target "$(cat /cargo_arch)-unknown-linux-gnu" | ||
|
||
FROM debian:bookworm-20231030-slim | ||
RUN apt-get update && apt-get install -y iptables ca-certificates && rm -rf /var/ib/apt/lists/* | ||
RUN update-alternatives --set iptables /usr/sbin/iptables-legacy | ||
COPY --from=builder /workdir/target/*/eip-operator / | ||
COPY --from=builder /workdir/target/*/cilium-eip-no-masquerade-agent / | ||
COPY --from=builder /workdir/target/*/*/eip-operator / | ||
COPY --from=builder /workdir/target/*/*/cilium-eip-no-masquerade-agent / | ||
ENTRYPOINT ["./eip-operator"] |
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