-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
68 lines (50 loc) · 2.15 KB
/
Dockerfile
File metadata and controls
68 lines (50 loc) · 2.15 KB
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
65
66
67
68
# Stage 1: Build frontend
FROM node:22-bookworm-slim AS frontend
WORKDIR /build/frontend
COPY frontend/package.json frontend/package-lock.json ./
RUN npm ci
COPY frontend/ ./
RUN npm run build
# Stage 2: Build Rust binary
FROM rust:1.85-bookworm AS builder
ARG VERSION
WORKDIR /build
# Copy workspace manifests first for layer caching
COPY Cargo.toml Cargo.lock ./
COPY crates/flowcus-core/Cargo.toml crates/flowcus-core/Cargo.toml
COPY crates/flowcus-ipfix/Cargo.toml crates/flowcus-ipfix/Cargo.toml
COPY crates/flowcus-storage/Cargo.toml crates/flowcus-storage/Cargo.toml
COPY crates/flowcus-query/Cargo.toml crates/flowcus-query/Cargo.toml
COPY crates/flowcus-server/Cargo.toml crates/flowcus-server/Cargo.toml
COPY crates/flowcus-app/Cargo.toml crates/flowcus-app/Cargo.toml
# Inject version from build arg if provided
RUN if [ -n "$VERSION" ]; then \
sed -i "s/^version = \".*\"/version = \"$VERSION\"/" Cargo.toml; \
fi
# Create stub lib.rs files so cargo can resolve the workspace
RUN for crate in flowcus-core flowcus-ipfix flowcus-storage flowcus-query flowcus-server; do \
mkdir -p crates/$crate/src && echo "" > crates/$crate/src/lib.rs; \
done && \
mkdir -p crates/flowcus-app/src && echo "fn main() {}" > crates/flowcus-app/src/main.rs
# Pre-build dependencies (cached layer)
RUN cargo build --release --workspace 2>/dev/null || true
# Copy frontend build output
COPY --from=frontend /build/frontend/dist/ frontend/dist/
# Copy real source code
COPY crates/ crates/
# Re-inject version after full source copy (Cargo.toml was overwritten)
RUN if [ -n "$VERSION" ]; then \
sed -i "s/^version = \".*\"/version = \"$VERSION\"/" Cargo.toml; \
fi
# Build the actual binary
RUN touch crates/*/src/*.rs crates/flowcus-app/src/main.rs && \
cargo build --release -p flowcus-app
# Stage 3: Minimal runtime
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates curl && \
rm -rf /var/lib/apt/lists/*
COPY --from=builder /build/target/release/flowcus /usr/local/bin/flowcus
RUN mkdir -p /data/storage
EXPOSE 2137 4739/udp
ENTRYPOINT ["flowcus"]
CMD ["--storage", "/data/storage"]