-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
75 lines (55 loc) · 1.94 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
FROM python:3.10-slim AS builder
WORKDIR /app
RUN \
apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
git \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# initialize venv
RUN python -m venv /opt/venv
# activate venv
ENV PATH="/opt/venv/bin:$PATH"
# upgrade venv deps
RUN pip install --no-cache-dir --upgrade \
pip \
setuptools \
wheel
COPY requirements.txt /app
RUN pip install --no-cache-dir -r /app/requirements.txt
COPY . /app
# inject railway env vars
ARG RAILWAY_GIT_COMMIT_SHA
ARG RAILWAY_GIT_BRANCH
RUN \
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 ; \
rm -rf .git .github config docs && \
ls -la ; \
cat .version
#----------------------------------------
FROM python:3.10-slim
# install fonts
RUN \
apt-get update && \
apt-get install -y --no-install-recommends \
fonts-wqy-microhei \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# install wkhtmltopdf # hmmm, wkhtmltopdf works strangely...
#RUN \
# apt-get update && apt-get -y install wget && \
# wget "https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.buster_$(dpkg --print-architecture).deb" -O /tmp/wkhtmltopdf.deb && \
# dpkg -i /tmp/wkhtmltopdf.deb && apt-get -f install && \
# rm -f /tmp/wkhtmltopdf.deb && apt-get purge wget --auto-remove
WORKDIR /app
COPY --from=builder /opt/venv /opt/venv
COPY --from=builder /app /app
# activate venv
ENV PATH="/opt/venv/bin:$PATH"
ENV PYTHONUNBUFFERED=1
CMD ["python", "-u", "telegramRSSbot.py"]