Decrease image size, use pyinstaller

This commit is contained in:
t3chn0m4g3 2024-11-26 13:38:26 +01:00
parent 626b657082
commit d28fcb6a22
3 changed files with 20 additions and 26 deletions

View file

@ -1,7 +1,7 @@
FROM alpine:3.20 AS builder FROM alpine:3.20 AS builder
# #
# Install packages # Install packages
RUN apk --no-cache add \ RUN apk --no-cache -U add \
build-base \ build-base \
git \ git \
libffi \ libffi \

View file

@ -46,9 +46,9 @@ RUN pyinstaller ddospot.py \
--hidden-import twisted.internet.reactor \ --hidden-import twisted.internet.reactor \
--hidden-import twisted.names.client \ --hidden-import twisted.names.client \
--hidden-import twisted.names.server \ --hidden-import twisted.names.server \
--hidden-import=twisted.python \ --hidden-import twisted.python \
--hidden-import=OpenSSL.crypto \ --hidden-import OpenSSL.crypto \
--hidden-import=OpenSSL.SSL --hidden-import OpenSSL.SSL
# #
FROM alpine:3.20 FROM alpine:3.20
COPY --from=builder /opt/ddospot/ddospot/dist/ddospot/ /opt/ddospot/ddospot COPY --from=builder /opt/ddospot/ddospot/dist/ddospot/ /opt/ddospot/ddospot

View file

@ -1,4 +1,4 @@
FROM alpine:3.19 FROM alpine:3.20 AS builder
# #
# Include dist # Include dist
COPY dist/ /root/dist/ COPY dist/ /root/dist/
@ -33,27 +33,21 @@ RUN apk --no-cache -U add \
git clone https://gitlab.com/bontchev/elasticpot.git/ && \ git clone https://gitlab.com/bontchev/elasticpot.git/ && \
cd elasticpot && \ cd elasticpot && \
git checkout d12649730d819bd78ea622361b6c65120173ad45 && \ git checkout d12649730d819bd78ea622361b6c65120173ad45 && \
cp /root/dist/requirements.txt . && \ cp /root/dist/requirements.txt .
pip3 install --break-system-packages -r requirements.txt && \ WORKDIR /opt/elasticpot
RUN pip3 install --break-system-packages pyinstaller
RUN pip3 install --break-system-packages -r requirements.txt
RUN pyinstaller elasticpot.py \
--hidden-import output_plugins \
--hidden-import output_plugins.jsonlog
# #
# Setup user, groups and configs FROM alpine:3.20
addgroup -g 2000 elasticpot && \ COPY --from=builder /opt/elasticpot/dist/ /opt/
adduser -S -H -s /bin/ash -u 2000 -D -g 2000 elasticpot && \ COPY --from=builder /opt/elasticpot/responses/ /opt/elasticpot/responses/
mv /root/dist/honeypot.cfg /opt/elasticpot/etc/ && \ COPY --from=builder /root/dist/honeypot.cfg /opt/elasticpot/etc/
#
# Clean up
apk del --purge build-base \
git \
libffi-dev \
openssl-dev \
postgresql-dev \
python3-dev && \
rm -rf /root/* \
/var/cache/apk/* \
/opt/elasticpot/.git
# #
# Start elasticpot # Start elasticpot
STOPSIGNAL SIGINT STOPSIGNAL SIGINT
USER elasticpot:elasticpot USER 2000:2000
WORKDIR /opt/elasticpot/ WORKDIR /opt/elasticpot/
CMD ["/usr/bin/python3","elasticpot.py"] CMD ["./elasticpot"]