-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
85 lines (65 loc) · 2.18 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# syntax=docker/dockerfile:1
ARG alpine_version=3.20
ARG python_version=3.12
ARG webchanges_tag=v3.26.0
FROM python:${python_version}-alpine${alpine_version} AS builder
ARG webchanges_tag
ENV PYTHONUTF8=1
RUN apk add --no-cache \
binutils \
gcc \
libc-dev \
libffi-dev \
upx
# Update pip, setuptools and wheel, install pyinstaller
RUN python3 -m pip install --upgrade \
pip \
setuptools \
wheel \
&& python3 -m pip install pyinstaller
# Get latest webchanges source, checkout tag
ADD https://github.com/mborsetti/webchanges.git#${webchanges_tag} /webchanges
WORKDIR /webchanges
# Install requirements and webchanges from source
RUN python3 -m pip install -r requirements.txt \
&& python3 -m pip install .
# Install some additional packages used by webchanges (optional)
# see https://webchanges.readthedocs.io/en/stable/dependencies.html
RUN python3 -m pip install \
html5lib \
beautifulsoup4 \
jsbeautifier \
cssbeautifier \
jq \
chump \
pyopenssl \
minidb \
python-dateutil \
zstandard \
vobject
# Copy entrypoint script
COPY webchanges.py webchanges.py
# Monkeypatch to avoid cli output refering to "webchanges" as "webchanges.__init__"
RUN sed -i 's/__project_name__ = __package__/__project_name__ = "webchanges"/g' ./webchanges/__init__.py
# Build the executable file (-F) and strip debug symbols
# Use pythons optimize flag (-OO) to remove doc strings, assert statements, sets __debug__ to false
# (not possible with webchanges, no cli output otherwise)
RUN python3 -m PyInstaller -F --strip webchanges.py
# Debug: list warnings
# RUN cat build/cli/warn-cli.txt
FROM alpine:${alpine_version} AS deploy
ENV APP_USER=webchanges
ENV PYTHONUTF8=1
RUN apk add --no-cache tini
COPY --from=builder /webchanges/dist/webchanges /usr/local/bin/webchanges
RUN addgroup $APP_USER
RUN adduser --disabled-password --ingroup $APP_USER $APP_USER
RUN mkdir -p /data/webchanges \
&& chown -R $APP_USER:$APP_USER /data/webchanges \
&& chmod 0755 /data/webchanges
VOLUME /data/webchanges
RUN rm /var/spool/cron/crontabs/root
COPY crontabfile ./crontabfile
COPY run.sh ./run.sh
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["/bin/sh", "run.sh"]