-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
49 lines (35 loc) · 1.27 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
FROM python:3.10.5-slim-bullseye AS build
ARG SECRET_KEY
ARG DATABASE_URL
ARG SIGNING_SECRET
ARG SLACK_BOT_TOKEN
ARG ENABLE_SCHEDULER
ENV SECRET_KEY=${SECRET_KEY}
ENV DATABASE_URL=${DATABASE_URL}
ENV SIGNING_SECRET=${SIGNING_SECRET}
ENV SLACK_BOT_TOKEN=${SLACK_BOT_TOKEN}
ENV ENABLE_SCHEDULER=${ENABLE_SCHEDULER}
WORKDIR /votebot
RUN mkdir log/
RUN touch log/access.log
RUN touch log/error.log
COPY requirements/prod.txt ./requirements.txt
RUN pip install -r requirements.txt --no-cache-dir && \
adduser lime && \
chown -R lime /votebot
COPY bot_app ./bot_app
COPY bot_project ./bot_project
COPY manage.py ./
FROM build AS production
RUN chown lime:lime -R /votebot
RUN chmod u+x manage.py
USER lime
ENTRYPOINT ["/bin/sh", "-c", "./manage.py makemigrations && ./manage.py migrate && gunicorn bot_project.wsgi:application -b 0.0.0.0:8000 --timeout 10 --workers 2 --preload --capture-output --log-level debug"]
FROM build AS tests
COPY requirements/dev.txt ./requirements.txt
COPY tests ./tests
RUN pip install -r requirements.txt --no-cache-dir
RUN chmod u+x manage.py
RUN chown lime:lime -R /votebot
USER lime
ENTRYPOINT ["/bin/sh", "-c", "./manage.py makemigrations && ./manage.py migrate && coverage run --source='./bot_app' manage.py test --verbosity=3 && coverage report -m"]