forked from TitanEmbeds/Titan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
102 lines (73 loc) · 2.34 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
98
99
100
FROM python:3.11-slim-bullseye as base
RUN useradd -ms /bin/bash titan
WORKDIR /home/titan/Titan
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
RUN apt update && \
apt install --no-install-recommends -y \
redis-tools && \
rm -rf /var/lib/apt/lists/*
FROM base as build
ARG VIRTUAL_ENV="/home/titan/venv"
ENV VIRTUAL_ENV=$VIRTUAL_ENV
ARG PATH="$VIRTUAL_ENV/bin":$PATH
ENV PATH=$PATH
RUN apt update && \
apt install --no-install-recommends -y \
build-essential \
python-dev && \
rm -rf /var/lib/apt/lists/*
RUN python -mvenv $VIRTUAL_ENV
RUN pip install -U pip wheel
FROM build as build-discordbot
ARG VIRTUAL_ENV="/home/titan/venv"
ENV VIRTUAL_ENV=$VIRTUAL_ENV
ARG PATH="$VIRTUAL_ENV/bin":$PATH
ENV PATH=$PATH
COPY discordbot/requirements.txt .
RUN pip install -r requirements.txt
FROM build as build-webapp
ARG VIRTUAL_ENV="/home/titan/venv"
ENV VIRTUAL_ENV=$VIRTUAL_ENV
ARG PATH="$VIRTUAL_ENV/bin":$PATH
ENV PATH=$PATH
COPY webapp/requirements.txt .
RUN pip install -r requirements.txt
FROM base as discordbot
ARG VIRTUAL_ENV="/home/titan/venv"
ENV VIRTUAL_ENV=$VIRTUAL_ENV
ARG PATH="$VIRTUAL_ENV/bin":$PATH
ENV PATH=$PATH
ENV DATABASE_URL='postgresql://titan:titan@localhost:5432/titan'
ENV REDIS_URL='redis://localhost'
ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 1
ARG GIT_COMMIT
ENV GIT_COMMIT=$GIT_COMMIT
ARG TITAN_BOT_PORT
ENV TITAN_BOT_PORT=8080
COPY --from=build-discordbot /home/titan/venv /home/titan/venv
COPY discordbot discordbot/
USER titan
WORKDIR /home/titan/Titan/discordbot
CMD ["python", "run.py"]
FROM base as webapp
ARG VIRTUAL_ENV="/home/titan/venv"
ENV VIRTUAL_ENV=$VIRTUAL_ENV
ARG PATH="$VIRTUAL_ENV/bin":$PATH
ENV PATH=$PATH
ENV DATABASE_URL='postgresql://titan:titan@localhost:5432/titan'
ENV REDIS_URL='redis://localhost'
ENV TITAN_HTTPS_PROXY='True'
ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 1
ARG GIT_COMMIT
ENV GIT_COMMIT=$GIT_COMMIT
ARG TITAN_BOT_PORT
ENV TITAN_BOT_PORT=8080
COPY --from=build-webapp /home/titan/venv /home/titan/venv
COPY webapp webapp/
RUN cd webapp && python bin/tr_compile.py
USER titan
WORKDIR /home/titan/Titan/webapp
CMD ["gunicorn", "--worker-class", "eventlet", "-w", "1", "-b", "0.0.0.0:8080", "--log-level", "info", "--access-logfile", "-", "--error-logfile", "-", "--access-logformat", "%(h)s %(l)s %(u)s '%(r)s' %(s)s %(b)s '%(f)s' '%(a)s'" , "titanembeds.app:app"]