-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.monitor
More file actions
58 lines (44 loc) · 1.38 KB
/
Dockerfile.monitor
File metadata and controls
58 lines (44 loc) · 1.38 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
# Dockerfile for network monitor
FROM rust:1.88-alpine AS builder
# Install build dependencies
RUN apk add --no-cache \
musl-dev \
pkgconfig
# Create app directory
WORKDIR /app
# Copy source files
COPY Cargo.toml Cargo.lock ./
COPY src ./src
# Build only the network-monitor binary
RUN cargo build --release --bin network-monitor --target x86_64-unknown-linux-musl
# Runtime stage
FROM alpine:3.19
# Install runtime dependencies
RUN apk add --no-cache \
ca-certificates \
iproute2 \
iptables \
tcpdump \
curl
# Create non-root user for monitor
RUN addgroup -g 1000 monitor && \
adduser -D -u 1000 -G monitor monitor
# Copy binary from builder
COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/network-monitor /usr/local/bin/network-monitor
# Create necessary directories
RUN mkdir -p /data /logs && \
chown -R monitor:monitor /data /logs
# Copy monitoring scripts
COPY network-policy/monitor-traffic.sh /usr/local/bin/monitor-traffic.sh
RUN chmod +x /usr/local/bin/monitor-traffic.sh
# Switch to non-root user (but will need CAP_NET_ADMIN)
USER monitor
WORKDIR /home/monitor
# Default environment variables
ENV RUST_LOG=info
ENV MONITOR_INTERVAL=5
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD ps aux | grep -q network-monitor || exit 1
# Default command
ENTRYPOINT ["/usr/local/bin/network-monitor"]