-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile-slim
49 lines (40 loc) · 1.15 KB
/
Dockerfile-slim
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
# Stage 1: Build
FROM rust:latest AS builder
# Install build dependencies
RUN apt-get update && apt-get install -y \
libpcap-dev \
iproute2 \
&& rustup toolchain install stable \
&& rustup toolchain install nightly --component rust-src \
&& cargo install bpf-linker \
&& rm -rf /var/lib/apt/lists/*
# Set environment variables
ENV PATH="/root/.cargo/bin:${PATH}"
# Copy source code
WORKDIR /usr/src/app
COPY Cargo.toml ./
COPY .cargo ./.cargo
COPY common ./common
COPY rustiflow ./rustiflow
COPY xtask ./xtask
COPY rustfmt.toml .
COPY ebpf-ipv4 ./ebpf-ipv4
COPY ebpf-ipv6 ./ebpf-ipv6
# Build the project
RUN cargo xtask ebpf-ipv4 --release && \
cargo xtask ebpf-ipv6 --release && \
cargo build --release
# Stage 2: Runtime
FROM debian:bookworm-slim
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
libpcap0.8 \
iproute2 \
--no-install-recommends && \
rm -rf /var/lib/apt/lists/*
# Copy the compiled binaries from the builder stage
COPY --from=builder /usr/src/app/target/release/rustiflow /usr/local/bin/rustiflow
# Set environment variables
ENV RUST_LOG=info
# Command
ENTRYPOINT ["rustiflow"]