bump to alpine:3.20 and optimize image using either from:scratch or pyinstaller

This commit is contained in:
t3chn0m4g3 2024-12-04 20:52:30 +01:00
parent 2747719f05
commit b75e22cabc
7 changed files with 47 additions and 59 deletions

View file

@ -17,10 +17,8 @@ RUN apk --no-cache -U add \
RUN git clone https://github.com/nsmfoo/dicompot.git && \ RUN git clone https://github.com/nsmfoo/dicompot.git && \
cd dicompot && \ cd dicompot && \
git checkout 41331194156bbb17078bcc1594f4952ac06a731e && \ git checkout 41331194156bbb17078bcc1594f4952ac06a731e && \
cp /root/dist/go.mod . && \ cp /root/dist/go.mod .
pwd && ls -alR
WORKDIR /go/dicompot WORKDIR /go/dicompot
RUN ls -alR
RUN go mod tidy RUN go mod tidy
RUN go mod download RUN go mod download
RUN go build -o dicompot github.com/nsmfoo/dicompot/server RUN go build -o dicompot github.com/nsmfoo/dicompot/server

View file

@ -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 # Install packages
RUN apk --no-cache -U add \ RUN apk --no-cache -U add \
build-base \ build-base \
git \ git \
go \ g++
g++ && \
# #
# Setup go, build medpot # Setup go, build medpot
export GOPATH=/opt/go/ && \ RUN mkdir -p /usr/local/go/src/medpot && \
export GO111MODULE=off && \ git clone https://github.com/schmalle/medpot /usr/local/go/src/medpot && \
mkdir -p /opt/go/src && \ cd /usr/local/go/src/medpot && \
cd /opt/go/src && \
git clone https://github.com/schmalle/medpot && \
cd medpot && \
git checkout 75a2e6134cf926c35b6017d62542274434c87388 && \ git checkout 75a2e6134cf926c35b6017d62542274434c87388 && \
cd .. && \ go mod init github.com/schmalle/medpot && \
go get -d -v github.com/davecgh/go-spew/spew && \ go mod tidy && \
go get -d -v github.com/go-ini/ini && \ go mod download && \
go get -d -v github.com/mozillazg/request && \
go get -d -v go.uber.org/zap && \
cd medpot && \
cp dist/etc/ews.cfg /etc/ && \ cp dist/etc/ews.cfg /etc/ && \
go build medpot go build medpot
# #
FROM alpine:3.19 FROM scratch
# #
# Setup medpot # Setup medpot
# #
COPY --from=builder /opt/go/src/medpot/medpot /opt/medpot/medpot COPY --from=builder /usr/local/go/src/medpot/medpot /opt/medpot/medpot
COPY --from=builder /opt/go/src/medpot/template/*.xml /opt/medpot/ COPY --from=builder /usr/local/go/src/medpot/template/*.xml /opt/medpot/
COPY --from=builder /opt/go/src/medpot/dist/etc/ews.cfg /etc/ews.cfg COPY --from=builder /usr/local/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
# #
# Start medpot # Start medpot
WORKDIR /opt/medpot WORKDIR /opt/medpot
USER medpot:medpot USER 2000:2000
CMD ["./medpot"] CMD ["./medpot"]

View file

@ -1,26 +1,29 @@
FROM alpine:3.19 FROM alpine:3.20 AS builder
# #
# Install packages # Install packages
RUN apk --no-cache -U add \ RUN apk --no-cache -U add \
build-base \
git \ git \
python3 \ python3 \
py3-pip && \ py3-pip
mkdir -p /opt && \ #
RUN mkdir -p /opt && \
cd /opt/ && \ cd /opt/ && \
git clone https://github.com/t3chn0m4g3/miniprint && \ git clone https://github.com/t3chn0m4g3/miniprint
cd miniprint && \ WORKDIR /opt/miniprint
pip3 install --break-system-packages -r requirements.txt && \ 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 FROM alpine:3.20
addgroup -g 2000 miniprint && \ COPY --from=builder /opt/miniprint/dist/* /opt/miniprint/
adduser -S -H -s /bin/ash -u 2000 -D -g 2000 miniprint && \ COPY --from=builder /opt/miniprint/fake-files/ /opt/miniprint/fake-files/
# COPY --from=builder /opt/miniprint/uploads/ /opt/miniprint/uploads/
# Clean up
apk del --purge git && \
rm -rf /root/* /var/cache/apk/* /opt/miniprint/.git
# #
# Start miniprint # Start miniprint
STOPSIGNAL SIGINT STOPSIGNAL SIGINT
USER miniprint:miniprint USER 2000:2000
WORKDIR /opt/miniprint/ 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"]

View file

@ -1,4 +1,4 @@
FROM alpine:3.19 FROM alpine:3.20
# #
# Add source # Add source
COPY . /opt/p0f COPY . /opt/p0f

View file

@ -1,4 +1,4 @@
FROM golang:1.21-alpine as builder FROM golang:1.23-alpine as builder
# #
# Include dist # Include dist
COPY dist/ /root/dist/ COPY dist/ /root/dist/
@ -20,19 +20,14 @@ RUN apk --no-cache -U add \
go mod download && \ go mod download && \
go install go install
# #
FROM alpine:3.19 FROM alpine:3.20
# #
# Setup redishoneypot # Setup redishoneypot
# #
COPY --from=builder /opt/go/bin/RedisHoneyPot /opt/redishoneypot/ COPY --from=builder /opt/go/bin/RedisHoneyPot /opt/redishoneypot/
COPY --from=builder /root/dist/redis.conf /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 # Start redishoneypot
WORKDIR /opt/redishoneypot WORKDIR /opt/redishoneypot
USER redishoneypot:redishoneypot USER 2000:2000
CMD ./RedisHoneyPot > /var/log/redishoneypot/redishoneypot.log 2>&1 CMD ./RedisHoneyPot > /var/log/redishoneypot/redishoneypot.log 2>&1

View file

@ -1,7 +1,8 @@
FROM alpine:edge FROM alpine:edge
# #
# Install packages # 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 && \ sentrypeer && \
# #
# Setup user, groups and configs # Setup user, groups and configs

View file

@ -1,4 +1,4 @@
FROM alpine:3.19 FROM alpine:3.20
# #
# Include dist # Include dist
COPY dist/ /root/dist/ COPY dist/ /root/dist/
@ -62,9 +62,9 @@ RUN apk --no-cache -U add \
git clone https://github.com/smicallef/spiderfoot /home/spiderfoot && \ git clone https://github.com/smicallef/spiderfoot /home/spiderfoot && \
cd /home/spiderfoot && \ cd /home/spiderfoot && \
git checkout 0f815a203afebf05c98b605dba5cf0475a0ee5fd && \ 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 . && \ 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 && \ mkdir -p /home/spiderfoot/.spiderfoot/logs && \
chown -R spiderfoot:spiderfoot /home/spiderfoot && \ chown -R spiderfoot:spiderfoot /home/spiderfoot && \
sed -i "s#'root': '\/'#'root': '\/spiderfoot'#" /home/spiderfoot/sf.py && \ sed -i "s#'root': '\/'#'root': '\/spiderfoot'#" /home/spiderfoot/sf.py && \