Skip to content

Commit 85d44cc

Browse files
committed
Improve Docker images and local container workflow
1 parent eb8fc7a commit 85d44cc

4 files changed

Lines changed: 47 additions & 11 deletions

File tree

.dockerignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
*
2+
!Cargo.toml
3+
!Cargo.lock
4+
!.cargo/
5+
!common/
6+
!rustiflow/
7+
!xtask/
8+
!rustfmt.toml
9+
!ebpf-ipv4/
10+
!ebpf-ipv6/

Dockerfile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
FROM ubuntu:20.04
1+
FROM ubuntu:24.04
22

33
ENV DEBIAN_FRONTEND=noninteractive
44

55
# Update the system and install dependencies
66
RUN apt-get update && apt-get install -y \
7+
ca-certificates \
78
curl \
89
build-essential \
10+
pkg-config \
911
libpcap-dev \
1012
iproute2 \
11-
linux-tools-5.8.0-63-generic \
1213
&& rm -rf /var/lib/apt/lists/*
1314

1415
# Install Rust
@@ -19,12 +20,12 @@ RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \
1920
&& cargo install bpf-linker
2021

2122
ENV PATH="/root/.cargo/bin:${PATH}"
22-
ENV PATH="/usr/lib/linux-tools/5.8.0-63-generic:$PATH"
2323
ENV RUST_LOG=info
2424

2525
# Copy
2626
WORKDIR /usr/src/app
2727
COPY Cargo.toml ./
28+
COPY Cargo.lock ./
2829
COPY .cargo ./.cargo
2930
COPY common ./common
3031
COPY rustiflow ./rustiflow
@@ -36,7 +37,7 @@ COPY ebpf-ipv6 ./ebpf-ipv6
3637
# Build
3738
RUN cargo xtask ebpf-ipv4 --release
3839
RUN cargo xtask ebpf-ipv6 --release
39-
RUN cargo build --release
40+
RUN cargo build --release --locked
4041

4142
# Command
42-
ENTRYPOINT ["./target/release/rustiflow"]
43+
ENTRYPOINT ["/usr/src/app/target/release/rustiflow"]

Dockerfile-slim

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# Stage 1: Build
2-
FROM rust:latest AS builder
2+
FROM rust:1-bookworm AS builder
33

44
# Install build dependencies
55
RUN 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
1719
WORKDIR /usr/src/app
1820
COPY Cargo.toml ./
21+
COPY Cargo.lock ./
1922
COPY .cargo ./.cargo
2023
COPY common ./common
2124
COPY rustiflow ./rustiflow
@@ -27,20 +30,27 @@ COPY ebpf-ipv6 ./ebpf-ipv6
2730
# Build the project
2831
RUN 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
3336
FROM debian:bookworm-slim
3437

3538
# Install runtime dependencies
3639
RUN 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
4350
COPY --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
4656
ENV RUST_LOG=info

README.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,17 +130,32 @@ Make sure that you don't use docker desktop and that you don't have it installed
130130
```
131131
- **Run the Container**:
132132
```bash
133-
docker run --network host -v /path/on/host:/app rustiflow [ARGS like you are used to]
133+
docker run --rm --network host -v /path/on/host:/app rustiflow [ARGS]
134134
```
135-
Run it with the --privileged flag if you want to capture traffic in real-time.
135+
Run it with the `--privileged` flag if you want to capture traffic in real-time.
136136
- **Example**:
137137
```bash
138-
docker run --network host -v /home/user/pcap:/app rustiflow pcap basic-flow 60 /app/pcap.pcap print
138+
docker run --rm --network host -v /home/user/pcap:/app rustiflow \
139+
-f basic \
140+
-o print \
141+
pcap /app/pcap.pcap
139142
```
140143
```bash
141-
docker run --privileged --network host -v /home/matisse/Documents:/app rustiflow realtime enp5s0 cic-flow 60 csv /app/output.csv
144+
docker run --rm --privileged --network host -v /home/user/output:/app rustiflow \
145+
-f cic \
146+
-o csv \
147+
--export-path /app/output.csv \
148+
realtime enp5s0
142149
```
143150

151+
Notes:
152+
153+
- The current CLI uses flags such as `-f basic` and `-o csv`; the older
154+
positional examples are no longer correct.
155+
- Realtime capture in a container still depends on Linux host support for eBPF
156+
and `tc`, so `--privileged --network host` remains the practical baseline for
157+
local testing.
158+
144159
## <img src="figures/RustiFlow_nobg.png" width="60px"/> Installation Guide for development
145160

146161
### Prerequisites:

0 commit comments

Comments
 (0)