-
Notifications
You must be signed in to change notification settings - Fork 21
/
Dockerfile.core
94 lines (67 loc) · 1.96 KB
/
Dockerfile.core
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
FROM python:3.13-alpine3.21 AS build_shared
WORKDIR /build_shared/
RUN pip install --no-cache-dir build
COPY ./src/shared/. .
RUN python -m build
RUN apk add --no-cache \
gcc \
build-base\
libc-dev\
linux-headers
COPY ./src/core/sse/forward.c .
RUN gcc -o forward forward.c
FROM python:3.13-alpine3.21 AS production
WORKDIR /app/
# upgrade pip
RUN python -m pip install --upgrade pip
# install common packages
RUN \
apk add --no-cache \
postgresql-libs \
libpq \
curl \
openssl
# install "shared" package from build_shared stage
# TODO: somehow squash the following two layers into one to conserve space
COPY --from=build_shared /build_shared/dist/taranis_ng_shared-*.whl custom_packages/
RUN pip install --no-cache-dir ./custom_packages/taranis_ng_shared-*.whl && rm -rf ./custom_packages/
# install other dependencies
COPY ./src/core/requirements.txt /app/requirements.txt
RUN \
apk add --no-cache --virtual .build-deps \
gcc \
g++ \
git \
build-base\
libc-dev\
zlib-dev \
linux-headers \
make \
glib-dev \
musl-dev \
python3-dev \
libffi-dev \
postgresql-dev && \
pip install --no-cache-dir -r /app/requirements.txt && \
apk --purge del .build-deps
COPY --from=build_shared /build_shared/forward /usr/local/bin/forward
COPY ./docker/start.sh /start.sh
RUN chmod +x /start.sh
COPY ./docker/prestart_core.sh /app/prestart.sh
RUN chmod +x /app/prestart.sh
COPY ./docker/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
COPY ./docker/gunicorn_conf.py /gunicorn_conf.py
COPY ./src/core/. /app/
RUN chmod +x /app/manage.py && \
chmod +x /app/db_migration.py
EXPOSE 80
# setup environment variables
ENV PYTHONPATH=/app
ENV MODULE_NAME run
ENV VARIABLE_NAME app
ENV GUNICORN_CMD_ARGS --timeout 120
VOLUME ["/data"]
HEALTHCHECK --interval=5s --timeout=3s --retries=5 CMD curl --fail http://localhost/api/v1/isalive || exit 1
ENTRYPOINT ["/entrypoint.sh"]
CMD ["/start.sh"]