11# Stage 1: Build
2- FROM rust:latest AS builder
2+ FROM rust:1-bookworm AS builder
33
44# Install build dependencies
55RUN apt-get update && apt-get install -y \
6+ ca-certificates \
67 libpcap-dev \
8+ pkg-config \
79 iproute2 \
810 && rustup toolchain install stable \
911 && rustup toolchain install nightly --component rust-src \
@@ -16,6 +18,7 @@ ENV PATH="/root/.cargo/bin:${PATH}"
1618# Copy source code
1719WORKDIR /usr/src/app
1820COPY Cargo.toml ./
21+ COPY Cargo.lock ./
1922COPY .cargo ./.cargo
2023COPY common ./common
2124COPY rustiflow ./rustiflow
@@ -27,20 +30,27 @@ COPY ebpf-ipv6 ./ebpf-ipv6
2730# Build the project
2831RUN cargo xtask ebpf-ipv4 --release && \
2932 cargo xtask ebpf-ipv6 --release && \
30- cargo build --release
33+ cargo build --release --locked
3134
3235# Stage 2: Runtime
3336FROM debian:bookworm-slim
3437
3538# Install runtime dependencies
3639RUN apt-get update && apt-get install -y \
40+ ca-certificates \
3741 libpcap0.8 \
3842 iproute2 \
3943 --no-install-recommends && \
4044 rm -rf /var/lib/apt/lists/*
4145
46+ # Recreate the builder-time layout expected by the binary's relative eBPF path lookup.
47+ WORKDIR /usr/src/app
48+
4249# Copy the compiled binaries from the builder stage
4350COPY --from=builder /usr/src/app/target/release/rustiflow /usr/local/bin/rustiflow
51+ COPY --from=builder /usr/src/app/target/bpfel-unknown-none/release/rustiflow-ebpf-ipv4 /usr/src/app/target/bpfel-unknown-none/release/rustiflow-ebpf-ipv4
52+ COPY --from=builder /usr/src/app/target/bpfel-unknown-none/release/rustiflow-ebpf-ipv6 /usr/src/app/target/bpfel-unknown-none/release/rustiflow-ebpf-ipv6
53+ RUN mkdir -p /usr/src/app/rustiflow
4454
4555# Set environment variables
4656ENV RUST_LOG=info
0 commit comments