This repository has been archived by the owner on Feb 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDockerfile
80 lines (57 loc) · 2.21 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
ARG dialect=sqlite
FROM python:3.11-slim as poetry
ARG dialect=sqlite
ENV PATH "/root/.local/bin:${PATH}"
ENV PYTHONUNBUFFERED 1
WORKDIR /root
# see DOK-DL4006
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# skipcq: DOK-DL3008
RUN apt-get update && \
apt-get install curl -y --no-install-recommends && \
curl -sSL https://install.python-poetry.org | python -
COPY poetry.lock pyproject.toml ./
RUN poetry export --no-interaction -o requirements.txt --without-hashes -E ${dialect} --only main,docker
FROM python:3.11-slim as base
ENV PYTHONPATH "/app/pinger"
WORKDIR /app/pinger
RUN groupadd -g 5000 container && useradd -d /app -m -g container -u 5000 container
COPY locales/ locales/
COPY --from=poetry /root/requirements.txt ./
# skipcq: DOK-DL3013
RUN pip install --no-cache-dir -U pip && \
pip --no-cache-dir install -r requirements.txt && \
pybabel compile -d locales
COPY pinger_bot/ pinger_bot/
FROM base AS additional-steps-sqlite
ENV DB_URI "sqlite+aiosqlite:////app/pinger/data/database.db"
RUN mkdir data && touch data/database.db && \
echo "discord_token: PLACEHOLDER" >> config.yml && \
alembic -c pinger_bot/migrations/alembic.ini upgrade head && \
rm config.yml
VOLUME /app/pinger/data
FROM base AS additional-steps-mysql
# (`apt-get update` because without it `package not found`, even if this update already was in `base` step)
# skipcq: DOK-DL3008
RUN apt-get update && \
apt-get install libmariadb-dev -y --no-install-recommends
FROM base AS additional-steps-postgresql
# (`apt-get update` because without it `package not found`, even if this update already was in `base` step)
# skipcq: DOK-DL3008
RUN apt-get update && \
apt-get install libpq-dev -y --no-install-recommends
FROM base AS git
# Write version for the `/version` command
# (`apt-get update` because without it `package not found`, even if this update already was in `base` step)
# skipcq: DOK-DL3008
RUN apt-get update && \
apt-get install git -y --no-install-recommends
COPY .git .git
RUN git rev-parse HEAD > /commit.txt
# skipcq: DOK-DL3006
FROM additional-steps-${dialect} AS final
COPY --from=git /commit.txt commit.txt
RUN chown -R 5000:5000 /app
USER container
ENV PROD 1
CMD ["dumb-init", "python", "pinger_bot"]