From b75e22cabcce88f6def85122cc946806c982f080 Mon Sep 17 00:00:00 2001 From: t3chn0m4g3 Date: Wed, 4 Dec 2024 20:52:30 +0100 Subject: [PATCH] bump to alpine:3.20 and optimize image using either from:scratch or pyinstaller --- docker/dicompot/Dockerfile | 4 +-- docker/medpot/Dockerfile | 47 +++++++++++++-------------------- docker/miniprint/Dockerfile | 33 ++++++++++++----------- docker/p0f/Dockerfile | 2 +- docker/redishoneypot/Dockerfile | 11 +++----- docker/sentrypeer/Dockerfile | 3 ++- docker/spiderfoot/Dockerfile | 6 ++--- 7 files changed, 47 insertions(+), 59 deletions(-) diff --git a/docker/dicompot/Dockerfile b/docker/dicompot/Dockerfile index 0e274fff..b4d6e337 100644 --- a/docker/dicompot/Dockerfile +++ b/docker/dicompot/Dockerfile @@ -17,10 +17,8 @@ RUN apk --no-cache -U add \ RUN git clone https://github.com/nsmfoo/dicompot.git && \ cd dicompot && \ git checkout 41331194156bbb17078bcc1594f4952ac06a731e && \ - cp /root/dist/go.mod . && \ - pwd && ls -alR + cp /root/dist/go.mod . WORKDIR /go/dicompot -RUN ls -alR RUN go mod tidy RUN go mod download RUN go build -o dicompot github.com/nsmfoo/dicompot/server diff --git a/docker/medpot/Dockerfile b/docker/medpot/Dockerfile index 666189e0..4e3082df 100644 --- a/docker/medpot/Dockerfile +++ b/docker/medpot/Dockerfile @@ -1,44 +1,35 @@ -FROM golang:1.21-alpine AS builder +FROM golang:1.23-alpine AS builder +# +ENV GO111MODULE=on \ + CGO_ENABLED=0 \ + GOOS=linux # # Install packages RUN apk --no-cache -U add \ - build-base \ - git \ - go \ - g++ && \ + build-base \ + git \ + g++ # # Setup go, build medpot - export GOPATH=/opt/go/ && \ - export GO111MODULE=off && \ - mkdir -p /opt/go/src && \ - cd /opt/go/src && \ - git clone https://github.com/schmalle/medpot && \ - cd medpot && \ +RUN mkdir -p /usr/local/go/src/medpot && \ + git clone https://github.com/schmalle/medpot /usr/local/go/src/medpot && \ + cd /usr/local/go/src/medpot && \ git checkout 75a2e6134cf926c35b6017d62542274434c87388 && \ - cd .. && \ - go get -d -v github.com/davecgh/go-spew/spew && \ - go get -d -v github.com/go-ini/ini && \ - go get -d -v github.com/mozillazg/request && \ - go get -d -v go.uber.org/zap && \ - cd medpot && \ + go mod init github.com/schmalle/medpot && \ + go mod tidy && \ + go mod download && \ cp dist/etc/ews.cfg /etc/ && \ go build medpot # -FROM alpine:3.19 +FROM scratch # # Setup medpot # -COPY --from=builder /opt/go/src/medpot/medpot /opt/medpot/medpot -COPY --from=builder /opt/go/src/medpot/template/*.xml /opt/medpot/ -COPY --from=builder /opt/go/src/medpot/dist/etc/ews.cfg /etc/ews.cfg -RUN mkdir -p /var/log/medpot && \ -# -# Setup user, groups and configs - addgroup -g 2000 medpot && \ - adduser -S -s /bin/ash -u 2000 -D -g 2000 medpot && \ - chown -R medpot:medpot /var/log/medpot +COPY --from=builder /usr/local/go/src/medpot/medpot /opt/medpot/medpot +COPY --from=builder /usr/local/go/src/medpot/template/*.xml /opt/medpot/ +COPY --from=builder /usr/local/go/src/medpot/dist/etc/ews.cfg /etc/ews.cfg # # Start medpot WORKDIR /opt/medpot -USER medpot:medpot +USER 2000:2000 CMD ["./medpot"] diff --git a/docker/miniprint/Dockerfile b/docker/miniprint/Dockerfile index 85933517..8c5c1a41 100644 --- a/docker/miniprint/Dockerfile +++ b/docker/miniprint/Dockerfile @@ -1,26 +1,29 @@ -FROM alpine:3.19 +FROM alpine:3.20 AS builder # # Install packages RUN apk --no-cache -U add \ + build-base \ git \ python3 \ - py3-pip && \ - mkdir -p /opt && \ + py3-pip +# +RUN mkdir -p /opt && \ cd /opt/ && \ - git clone https://github.com/t3chn0m4g3/miniprint && \ - cd miniprint && \ - pip3 install --break-system-packages -r requirements.txt && \ + git clone https://github.com/t3chn0m4g3/miniprint +WORKDIR /opt/miniprint +RUN pip3 install --break-system-packages pyinstaller +RUN pip3 install --break-system-packages -r requirements.txt +RUN pyinstaller server.py \ + --add-data "./fake-files:./fake-files" \ + --add-data "./uploads:./uploads" # -# Setup user, groups and configs - addgroup -g 2000 miniprint && \ - adduser -S -H -s /bin/ash -u 2000 -D -g 2000 miniprint && \ -# -# Clean up - apk del --purge git && \ - rm -rf /root/* /var/cache/apk/* /opt/miniprint/.git +FROM alpine:3.20 +COPY --from=builder /opt/miniprint/dist/* /opt/miniprint/ +COPY --from=builder /opt/miniprint/fake-files/ /opt/miniprint/fake-files/ +COPY --from=builder /opt/miniprint/uploads/ /opt/miniprint/uploads/ # # Start miniprint STOPSIGNAL SIGINT -USER miniprint:miniprint +USER 2000:2000 WORKDIR /opt/miniprint/ -CMD ["/usr/bin/python3", "./server.py", "--bind", "0.0.0.0", "--log-file", "log/miniprint.json"] +CMD ["./server", "--bind", "0.0.0.0", "--log-file", "/opt/miniprint/log/miniprint.json"] diff --git a/docker/p0f/Dockerfile b/docker/p0f/Dockerfile index 4d7af3b9..6c3f69fa 100644 --- a/docker/p0f/Dockerfile +++ b/docker/p0f/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:3.19 +FROM alpine:3.20 # # Add source COPY . /opt/p0f diff --git a/docker/redishoneypot/Dockerfile b/docker/redishoneypot/Dockerfile index 4fabfa55..20071b87 100644 --- a/docker/redishoneypot/Dockerfile +++ b/docker/redishoneypot/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.21-alpine as builder +FROM golang:1.23-alpine as builder # # Include dist COPY dist/ /root/dist/ @@ -20,19 +20,14 @@ RUN apk --no-cache -U add \ go mod download && \ go install # -FROM alpine:3.19 +FROM alpine:3.20 # # Setup redishoneypot # COPY --from=builder /opt/go/bin/RedisHoneyPot /opt/redishoneypot/ COPY --from=builder /root/dist/redis.conf /opt/redishoneypot/ # -# Setup user, groups and configs -RUN addgroup -g 2000 redishoneypot && \ - adduser -S -s /bin/ash -u 2000 -D -g 2000 redishoneypot && \ - mkdir -p /var/log/redishoneypot -# # Start redishoneypot WORKDIR /opt/redishoneypot -USER redishoneypot:redishoneypot +USER 2000:2000 CMD ./RedisHoneyPot > /var/log/redishoneypot/redishoneypot.log 2>&1 diff --git a/docker/sentrypeer/Dockerfile b/docker/sentrypeer/Dockerfile index 88de6907..9356d204 100644 --- a/docker/sentrypeer/Dockerfile +++ b/docker/sentrypeer/Dockerfile @@ -1,7 +1,8 @@ FROM alpine:edge # # Install packages -RUN apk -U add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing \ +RUN apk -U upgrade --no-cache && \ + apk -U add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing \ sentrypeer && \ # # Setup user, groups and configs diff --git a/docker/spiderfoot/Dockerfile b/docker/spiderfoot/Dockerfile index e7dbb6e1..813e3d36 100644 --- a/docker/spiderfoot/Dockerfile +++ b/docker/spiderfoot/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:3.19 +FROM alpine:3.20 # # Include dist COPY dist/ /root/dist/ @@ -62,9 +62,9 @@ RUN apk --no-cache -U add \ git clone https://github.com/smicallef/spiderfoot /home/spiderfoot && \ cd /home/spiderfoot && \ git checkout 0f815a203afebf05c98b605dba5cf0475a0ee5fd && \ - pip3 install --break-system-packages --upgrade pip && \ + pip3 install --no-cache-dir --break-system-packages --upgrade pip && \ cp /root/dist/requirements.txt . && \ - pip3 install --break-system-packages --no-cache-dir -r requirements.txt && \ + pip3 install --no-cache-dir --break-system-packages --no-cache-dir -r requirements.txt && \ mkdir -p /home/spiderfoot/.spiderfoot/logs && \ chown -R spiderfoot:spiderfoot /home/spiderfoot && \ sed -i "s#'root': '\/'#'root': '\/spiderfoot'#" /home/spiderfoot/sf.py && \