Skip to content

Commit

Permalink
Merge pull request #471 from MaterializeInc/cross_compile
Browse files Browse the repository at this point in the history
Cross compile
  • Loading branch information
alex-hunt-materialize authored Jun 24, 2024
2 parents f24c25c + f8b97be commit 95e20f1
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 11 deletions.
14 changes: 12 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 21 additions & 8 deletions Dockerfile
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"]
2 changes: 1 addition & 1 deletion eip_operator_shared/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ futures = "0.3"
hyper = { version = "0.14.27", features = ["http2"] }
kube = { workspace = true }
kube-runtime = { workspace = true }
native-tls = { version = "0.2.11", features = ["alpn"] }
native-tls = { version = "0.2.11", features = ["alpn", "vendored"] }
opentelemetry = { version = "0.21", features = ["trace"] }
opentelemetry_sdk = { version = "0.21", features = ["trace", "rt-tokio"] }
opentelemetry-otlp = { version = "0.14" }
Expand Down

0 comments on commit 95e20f1

Please sign in to comment.