-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy pathDockerfile
More file actions
40 lines (32 loc) · 891 Bytes
/
Dockerfile
File metadata and controls
40 lines (32 loc) · 891 Bytes
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
# Multi-stage build for minimal final image
FROM alpine:3.20 AS builder
# Install build dependencies
RUN apk add --no-cache \
build-base \
autoconf \
automake \
libpcap-dev \
pcre2-dev \
libnet-dev
# Copy source code
WORKDIR /build
COPY . .
# Build ngrep
RUN ./configure --enable-ipv6 --enable-pcre2 --enable-tcpkill --prefix=/usr && \
make && \
make install DESTDIR=/install
# Final minimal image
FROM alpine:3.20
# Install only runtime dependencies
RUN apk add --no-cache \
libpcap \
pcre2 \
libnet
# Copy built binary from builder
COPY --from=builder /install/usr/bin/ngrep /usr/bin/ngrep
COPY --from=builder /install/usr/share/man/man8/ngrep.8 /usr/share/man/man8/ngrep.8
# ngrep needs to run as root or with NET_CAP_RAW capability
# Alpine uses musl libc which is smaller than glibc
USER root
ENTRYPOINT ["/usr/bin/ngrep"]
CMD ["-h"]