Skip to content

Commit 80fb0c4

Browse files
committed
initial commit for webchanges-docker
Signed-off-by: Christian König <[email protected]>
0 parents  commit 80fb0c4

File tree

6 files changed

+202
-0
lines changed

6 files changed

+202
-0
lines changed

Dockerfile

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
FROM python:3.11.3-alpine3.18 as builder
2+
ARG webchanges_tag=v3.15
3+
4+
RUN apk add --no-cache \
5+
binutils \
6+
git \
7+
upx
8+
9+
# Update pip, setuptools and wheel, install pyinstaller
10+
RUN python3 -m pip install --upgrade \
11+
pip \
12+
setuptools \
13+
wheel \
14+
&& python3 -m pip install pyinstaller
15+
16+
# Get latest webchanges source, checkout tag
17+
RUN git clone https://github.com/mborsetti/webchanges.git
18+
WORKDIR /webchanges
19+
RUN git checkout tags/${webchanges_tag} -b ${webchanges_tag}
20+
21+
# Install requirements and webchanges from source
22+
RUN python3 -m pip install -r requirements.txt \
23+
&& python3 -m pip install .
24+
25+
# Install some additional packages used by webchanges (optional)
26+
# see https://webchanges.readthedocs.io/en/stable/dependencies.html
27+
RUN python3 -m pip install \
28+
html5lib \
29+
beautifulsoup4 \
30+
jsbeautifier \
31+
cssbeautifier \
32+
jq \
33+
chump \
34+
pyopenssl
35+
36+
# Copy entrypoint script
37+
COPY webchanges.py webchanges.py
38+
39+
# Monkeypatch to avoid cli output refering to "webchanges" as "webchanges.__init__"
40+
RUN sed -i 's/__project_name__ = __package__/__project_name__ = "webchanges"/g' ./webchanges/__init__.py
41+
42+
# Build the executable file (-F) and strip debug symbols
43+
# Use pythons optimize flag (-OO) to remove doc strings, assert statements, sets __debug__ to false
44+
# (not possible with webchanges, no cli output otherwise)
45+
RUN python3 -m PyInstaller -F --strip webchanges.py
46+
47+
# Debug: list warnings
48+
# RUN cat build/cli/warn-cli.txt
49+
50+
51+
52+
FROM alpine:3.18 as deploy
53+
ENV APP_USER webchanges
54+
55+
COPY --from=builder /webchanges/dist/webchanges /usr/local/bin/webchanges
56+
57+
RUN addgroup $APP_USER
58+
RUN adduser --disabled-password --ingroup $APP_USER $APP_USER
59+
60+
RUN mkdir -p /data/webchanges \
61+
&& chown -R $APP_USER:$APP_USER /data/webchanges \
62+
&& chmod 0755 /data/webchanges
63+
64+
VOLUME /data/webchanges
65+
66+
RUN rm /var/spool/cron/crontabs/root
67+
68+
COPY crontabfile ./crontabfile
69+
COPY run.sh ./run.sh
70+
71+
CMD ["/bin/sh", "run.sh"]

crontabfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*/15 * * * * date && echo "Running webchanges" && cd /data/webchanges && webchanges --urls jobs.yaml --config config.yaml --cache cache.db

data/config.yaml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# webchanges configuration file. See https://webchanges.readthedocs.io/en/stable/configuration.html
2+
# Originally written on 2023-12-01T21:46:26Z by version 3.15.
3+
4+
display:
5+
new: true
6+
error: true
7+
unchanged: false
8+
empty-diff: true
9+
report:
10+
tz: null
11+
text:
12+
line_length: 75
13+
details: true
14+
footer: true
15+
minimal: false
16+
separate: false
17+
html:
18+
diff: unified
19+
separate: false
20+
markdown:
21+
details: true
22+
footer: true
23+
minimal: false
24+
separate: false
25+
stdout:
26+
enabled: true
27+
color: true
28+
browser:
29+
enabled: false
30+
title: '[webchanges] {count} changes: {jobs}'
31+
discord:
32+
enabled: false
33+
webhook_url: ''
34+
embed: true
35+
subject: '{count} changes: {jobs}'
36+
colored: true
37+
max_message_length: null
38+
email:
39+
enabled: false
40+
html: true
41+
from: ''
42+
to: ''
43+
subject: '[webchanges] {count} changes: {jobs}'
44+
method: smtp
45+
smtp:
46+
host: localhost
47+
port: 25
48+
starttls: true
49+
auth: true
50+
user: ''
51+
insecure_password: ''
52+
sendmail:
53+
path: sendmail
54+
ifttt:
55+
enabled: false
56+
key: ''
57+
event: ''
58+
mailgun:
59+
enabled: false
60+
region: us
61+
api_key: ''
62+
domain: ''
63+
from_mail: ''
64+
from_name: ''
65+
to: ''
66+
subject: '[webchanges] {count} changes: {jobs}'
67+
matrix:
68+
enabled: false
69+
homeserver: ''
70+
access_token: ''
71+
room_id: ''
72+
prowl:
73+
enabled: false
74+
api_key: ''
75+
priority: 0
76+
application: ''
77+
subject: '[webchanges] {count} changes: {jobs}'
78+
pushbullet:
79+
enabled: false
80+
api_key: ''
81+
pushover:
82+
enabled: false
83+
app: ''
84+
user: ''
85+
device: null
86+
sound: spacealarm
87+
priority: normal
88+
run_command:
89+
enabled: false
90+
command: ''
91+
telegram:
92+
enabled: false
93+
bot_token: ''
94+
chat_id: ''
95+
silent: false
96+
webhook:
97+
enabled: false
98+
webhook_url: ''
99+
markdown: false
100+
max_message_length: null
101+
xmpp:
102+
enabled: false
103+
sender: ''
104+
recipient: ''
105+
insecure_password: ''
106+
job_defaults:
107+
_note: Default directives that are applied to jobs.
108+
all:
109+
_note: These are used for all type of jobs, including those in hooks.py.
110+
url:
111+
_note: These are used for 'url' jobs without 'use_browser'.
112+
browser:
113+
_note: 'These are used for ''url'' jobs with ''use_browser: true''.'
114+
command:
115+
_note: These are used for 'command' jobs.
116+
database:
117+
engine: sqlite3
118+
max_snapshots: 4
119+
footnote: null
120+

data/jobs.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# webchanges jobs file. See https://webchanges.readthedocs.io/en/stable/jobs.html
2+

run.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
3+
crontab -u $APP_USER ./crontabfile
4+
crond -f -l 6

webchanges.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from webchanges.cli import main
2+
3+
if __name__ == '__main__':
4+
main()

0 commit comments

Comments
 (0)