-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathDockerfile
More file actions
69 lines (49 loc) · 1.82 KB
/
Dockerfile
File metadata and controls
69 lines (49 loc) · 1.82 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
69
# Multi-stage build
FROM rust:bookworm AS build
RUN apt-get update && apt-get install -y git
RUN git clone https://github.com/NLADC/pcap-converter /var/tmp/pcap-converter
WORKDIR /var/tmp/pcap-converter
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y autotools-dev autoconf make flex byacc git libtool pkg-config libbz2-dev
# Build pcap-converter
RUN cargo build --release
# Build and install nfdump
RUN git clone https://github.com/phaag/nfdump.git /app/nfdump
WORKDIR /app/nfdump
RUN ./autogen.sh && ./configure && make && make install && ldconfig
FROM python:3.11-slim-bookworm AS python
WORKDIR /app
ENV HOME=/app
# Create venv and set ENV accordingly
ENV VIRTUAL_ENV=/app/venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
COPY requirements.txt /app
RUN pip install --upgrade pip && \
pip install wheel && \
pip install -r /app/requirements.txt && \
pip cache purge
FROM python:3.11-slim-bookworm
ENV DISSECTOR_DOCKER=1
ARG DEBIAN_FRONTEND=noninteractive
# Leave out the following for a slim version (but can only use pcap-converter)
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y tshark tcpdump
# copy pcap-converter and nfdump from build stage
COPY --from=build /var/tmp/pcap-converter/target/release/pcap-converter /usr/bin/pcap-converter
COPY --from=build /usr/local/bin/nfdump /usr/local/bin/
COPY --from=build /usr/local/lib/* /usr/local/lib/
RUN ldconfig
WORKDIR /app
ENV HOME=/app
COPY --from=python /app/venv /app/venv
# Enable venv
ENV VIRTUAL_ENV=/app/venv
ENV PATH="/app/venv/bin:$PATH"
# Copy the source files to the image
COPY src/ /app
# Copy entrypoint.sh to the image
COPY entrypoint.sh /app
# Ensure intermediate files are stored on disk rather than tmpfs/RAM (default for /tmp)
ENV TMPDIR=/var/tmp
ENTRYPOINT ["/app/entrypoint.sh", "python", "main.py"]