1+ # Stage 1: Build stage
12FROM python:3.8 AS conpot-builder
23
4+ # Install required dependencies
35RUN apt-get update && apt-get install -y \
46 gcc \
7+ libffi-dev \
8+ libssl-dev \
59 && rm -rf /var/lib/apt/lists/*
610
7- # Copy the app from the host folder (probably a cloned repo) to the container
8- RUN adduser --disabled-password --gecos "" conpot
9-
10- COPY --chown=conpot:conpot . /opt/conpot/
11+ # Set working directory
12+ WORKDIR /opt/conpot
1113
12- # Install Conpot
13- USER conpot
14- ENV PATH=$PATH:/home/conpot/.local/bin
15- RUN pip3 install --user --no-cache-dir /opt/conpot
14+ # Copy the source code to the container
15+ COPY . .
1616
17+ # Install specific dependencies
18+ RUN pip3 install --no-cache-dir pysnmp==4.4.12 \
19+ && pip3 install --no-cache-dir pysmi==0.3.2 \
20+ && pip3 install --no-cache-dir pyasn1==0.4.8 \
21+ && pip3 install --no-cache-dir cryptography==3.4.8 \
22+ && pip3 install --no-cache-dir .
1723
18- # Run container
24+ # Stage 2: Runtime stage
1925FROM python:3.8-slim
2026
27+ # Install runtime dependencies
28+ RUN apt-get update && apt-get install -y \
29+ libffi-dev \
30+ libssl-dev \
31+ && rm -rf /var/lib/apt/lists/*
32+
33+ # Create non-root user
2134RUN adduser --disabled-password --gecos "" conpot
22- WORKDIR /home/conpot
2335
24- COPY --from=conpot-builder --chown=conpot:conpot /home/conpot/.local/ /home/conpot/.local/
36+ # Create required directories and set permissions
37+ RUN mkdir -p /var/log/conpot \
38+ && mkdir -p /usr/local/lib/python3.8/site-packages/conpot/tests/data/data_temp_fs/ftp \
39+ && mkdir -p /usr/local/lib/python3.8/site-packages/conpot/tests/data/data_temp_fs/tftp \
40+ && chown -R conpot:conpot /var/log/conpot \
41+ && chown -R conpot:conpot /usr/local/lib/python3.8/site-packages/conpot/tests/data
42+
43+ # Set working directory and copy dependencies from build stage
44+ WORKDIR /home/conpot
45+ COPY --from=conpot-builder /usr/local/lib/python3.8/ /usr/local/lib/python3.8/
46+ COPY --from=conpot-builder /usr/local/bin/ /usr/local/bin/
2547
26- # Create directories
27- RUN mkdir -p /var/log/conpot/ \
28- && mkdir -p /data/tftp/ \
29- && chown conpot:conpot /var/log/conpot \
30- && chown conpot:conpot -R /data
48+ # Set permissions for non-root user
49+ RUN chown -R conpot:conpot /home/conpot
3150
51+ # Switch to non-root user
3252USER conpot
33- WORKDIR /home/conpot
53+ ENV PATH=$PATH: /home/conpot/.local/bin
3454ENV USER=conpot
35- ENTRYPOINT ["/home/conpot/.local/bin/conpot" ]
36- CMD ["--template" , "default" , "--logfile" , "/var/log/conpot/conpot.log" , "-f" , "--temp_dir" , "/tmp" ]
55+
56+ # Set the default command
57+ ENTRYPOINT ["conpot" ]
58+ CMD ["--template" , "default" , "--logfile" , "/var/log/conpot/conpot.log" , "-f" , "--temp_dir" , "/tmp" ]
0 commit comments