-
Notifications
You must be signed in to change notification settings - Fork 43
/
Containerfile.dataplane
64 lines (51 loc) · 2.06 KB
/
Containerfile.dataplane
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
FROM rust:1.75-slim-bookworm as builder
ARG TARGETARCH
RUN apt-get update
RUN apt-get install --yes \
build-essential \
protobuf-compiler \
pkg-config \
llvm-16 \
musl-tools
RUN rustup default stable
RUN rustup install nightly
RUN rustup component add rust-src --toolchain nightly
RUN --mount=type=cache,target=/root/.cargo/registry \
cargo install bpf-linker
WORKDIR /workspace
# Docker uses the amd64/arm64 convention while Rust uses the x86_64/aarch64 convention.
# Since Dockerfile doesn't support conditional variables (sigh), write the arch in Rust's
# convention to a file for later usage.
RUN if [ "$TARGETARCH" = "amd64" ]; \
then echo "x86_64" >> arch; \
else echo "aarch64" >> arch; \
fi
RUN rustup target add $(eval cat arch)-unknown-linux-musl
COPY dataplane dataplane
COPY tools/udp-test-server tools/udp-test-server
COPY xtask xtask
COPY Cargo.toml Cargo.toml
COPY .cargo .cargo
# We need to tell bpf-linker where it can find LLVM's shared library file.
# Ref: https://github.com/aya-rs/rustc-llvm-proxy/blob/cbcb3c6/src/lib.rs#L48
ENV LD_LIBRARY_PATH="/usr/lib/llvm-16/lib"
RUN --mount=type=cache,target=/workspace/target/ \
--mount=type=cache,target=/root/.cargo/registry \
cargo xtask build-ebpf --release
RUN --mount=type=cache,target=/workspace/target/ \
--mount=type=cache,target=/root/.cargo/registry \
RUSTFLAGS=-Ctarget-feature=+crt-static cargo build \
--workspace \
--exclude ebpf \
--release \
--target=$(eval cat arch)-unknown-linux-musl
RUN --mount=type=cache,target=/workspace/target/ \
cp /workspace/target/$(eval cat arch)-unknown-linux-musl/release/loader /workspace/dataplane-release
FROM alpine
LABEL org.opencontainers.image.source=https://github.com/kubernetes-sigs/blixt
LABEL org.opencontainers.image.licenses=GPL-2.0-only,BSD-2-Clause
WORKDIR /opt/blixt/
COPY --from=builder /workspace/dataplane-release /opt/blixt/dataplane
COPY dataplane/LICENSE.GPL-2.0 /opt/blixt/LICENSE.GPL-2.0
COPY dataplane/LICENSE.BSD-2-Clause /opt/blixt/LICENSE.BSD-2-Clause
ENTRYPOINT ["/opt/blixt/dataplane"]