-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
67 lines (55 loc) · 2.04 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
FROM python:3.13.1-bookworm AS base
ENV PYTHONUNBUFFERED 1
ENV PROMETHEUS_MULTIPROC_DIR=prometheus_multi_proc_dir
ENV UWSGI_PROCESSES=1
ENV UWSGI_THREADS=1
ENV SERVICE_NAME=uwsgi
RUN mkdir build
WORKDIR /build
RUN addgroup --gid 2222 --system ${SERVICE_NAME} && \
adduser --gid 2222 --shell /bin/false --disabled-password --uid 2222 ${SERVICE_NAME}
RUN python -m venv /venv
ENV PATH="/venv/bin:$PATH"
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get update && apt-get install -y python3-pip nginx postgresql-client
FROM base AS poetry
RUN --mount=type=cache,target=/root/.cache/pip pip install poetry==1.8.2
COPY poetry.lock pyproject.toml ./
RUN poetry export -o /requirements.txt --without-hashes --without="dev" --without="docs"
RUN poetry export -o /requirements-docs.txt --without-hashes --only="docs"
FROM base AS docs
COPY docs docs
COPY Makefile .
COPY --from=poetry /requirements-docs.txt .
RUN --mount=type=cache,target=/root/.cache/pip pip install -r requirements-docs.txt
RUN make docs_build_pl
RUN make docs_build_en
FROM base AS build
COPY --from=docs /build/generated_docs generated_docs
COPY --from=poetry /requirements.txt .
RUN --mount=type=cache,target=/root/.cache/pip pip install -r requirements.txt
COPY base base
COPY config/twp_nginx.conf /etc/nginx/nginx.conf
COPY locale locale
COPY manage.py .
COPY metrics metrics
COPY pyproject.toml .
COPY rest_api rest_api
COPY scripts scripts
COPY LICENSE .
COPY templates templates
COPY tribal_wars_planer tribal_wars_planer
COPY utils utils
COPY setup.py setup.py
RUN python setup.py build_ext --inplace
RUN chown -R ${SERVICE_NAME}:${SERVICE_NAME} /build
CMD /build/scripts/init_webserver.sh
EXPOSE 80
EXPOSE 8050
FROM base AS translations
COPY --from=poetry /requirements.txt .
RUN --mount=type=cache,target=/root/.cache/pip pip install -r requirements.txt
RUN apt-get update -y && apt-get install gettext -y
CMD python manage.py makemessages --all --ignore .venv && \
python manage.py compilemessages --ignore .venv