forked from Rongronggg9/RSS-to-Telegram-Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
97 lines (73 loc) · 2.62 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
86
87
88
89
90
91
92
93
94
95
96
97
FROM python:3.10-bullseye AS dep-builder-common
ENV PATH="/opt/venv/bin:$PATH"
RUN \
set -ex && \
python -m venv --copies /opt/venv && \
pip install --no-cache-dir --upgrade \
pip setuptools wheel
COPY requirements.txt .
RUN \
set -ex && \
pip install --no-cache-dir \
-r requirements.txt \
&& \
rm -rf /opt/venv/src
#-----------------------------------------------------------------------------------------------------------------------
FROM python:3.10-bullseye AS dep-builder
ENV PATH="/opt/venv/bin:$PATH"
COPY --from=dep-builder-common /opt/venv /opt/venv
COPY requirements.txt .
ARG FEEDPARSER_ENHANCED=0
RUN \
set -ex && \
if [ "$FEEDPARSER_ENHANCED" = 1 ]; then \
pip uninstall -y feedparser && \
sed -i 's/^feedparser[^#]*#\s*//g' requirements.txt ; \
pip install --no-cache-dir \
-r requirements.txt \
; \
fi;
#-----------------------------------------------------------------------------------------------------------------------
FROM python:3.10-bullseye as app-builder
WORKDIR /app
COPY . /app
# inject railway env vars
ARG RAILWAY_GIT_COMMIT_SHA
ARG RAILWAY_GIT_BRANCH
RUN \
set -ex && \
echo "$(expr substr "$RAILWAY_GIT_COMMIT_SHA" 1 7)@$RAILWAY_GIT_BRANCH" | tee .version && \
if test $(expr length "$(cat .version)") -le 3; then \
echo "$(git describe --tags --always)@$(git branch --show-current)" | tee .version ; \
fi && \
if test $(expr length "$(cat .version)") -le 3; then \
echo "dirty-build@$(date -Iseconds)" | tee .version; else echo "build@$(date -Iseconds)" | tee -a .version; \
fi && \
mkdir /app-minimal && \
cp -r .version LICENSE src telegramRSSbot.py /app-minimal && \
cd / && \
rm -rf /app && \
rm -f /app-minimal/*.md && \
ls -la /app-minimal && \
du -hd1 /app-minimal && \
cat /app-minimal/.version
#-----------------------------------------------------------------------------------------------------------------------
FROM python:3.10-slim-bullseye as app
ENV PATH="/opt/venv/bin:$PATH" \
PYTHONUNBUFFERED=1 \
MALLOC_MMAP_THRESHOLD_=131072
WORKDIR /app
# install fonts
RUN \
set -ex && \
apt-get update && \
apt-get install -yq --no-install-recommends \
fonts-wqy-microhei dumb-init \
&& \
rm -rf /var/lib/apt/lists/*
COPY --from=dep-builder /opt/venv /opt/venv
COPY --from=app-builder /app-minimal /app
# verify cryptg installation
RUN python -c 'import logging; logging.basicConfig(level=logging.DEBUG); import telethon; import cryptg'
ENTRYPOINT ["dumb-init", "--"]
CMD ["python", "-u", "telegramRSSbot.py"]