-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
56 lines (45 loc) · 1.69 KB
/
Copy pathDockerfile
File metadata and controls
56 lines (45 loc) · 1.69 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
# Dockerfile for building file_monitor
# This provides a reproducible build environment for the eBPF file monitor
FROM rust:1.92-bookworm AS builder
# Install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
clang \
llvm \
libelf-dev \
linux-headers-generic \
pkg-config \
musl-tools \
&& rm -rf /var/lib/apt/lists/*
# Install Rust toolchains
RUN rustup toolchain install stable && \
rustup toolchain install nightly --component rust-src && \
rustup target add x86_64-unknown-linux-musl
# Install bpf-linker
RUN cargo install bpf-linker
# Set working directory
WORKDIR /workspace
# Copy the project files
COPY Cargo.toml Cargo.lock ./
COPY .cargo ./.cargo
COPY file_monitor ./file_monitor
COPY file_monitor-common ./file_monitor-common
COPY file_monitor-ebpf ./file_monitor-ebpf
# Build the project
# Using musl for static linking (easier deployment)
RUN cargo build --release --target x86_64-unknown-linux-musl
# Create a minimal runtime image
FROM scratch AS runtime
# Copy the binary from builder
COPY --from=builder /workspace/target/x86_64-unknown-linux-musl/release/file_monitor /file_monitor
# Note: This image cannot run directly as it requires kernel access for eBPF
# Extract the binary using:
# docker create --name temp file-monitor
# docker cp temp:/file_monitor ./file_monitor
# docker rm temp
# Alternatively, use the builder stage as a one-shot build container:
# docker run --rm -v $(pwd):/workspace file-monitor-builder \
# cargo build --release --target x86_64-unknown-linux-musl
# For the builder image, set the default command
FROM builder AS default
CMD ["cargo", "build", "--release", "--target", "x86_64-unknown-linux-musl"]