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 && \
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

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
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"]

View file

@ -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"]

View file

@ -1,4 +1,4 @@
FROM alpine:3.19
FROM alpine:3.20
#
# Add source
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
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

View file

@ -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

View file

@ -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 && \