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

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