-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathDockerfile
82 lines (72 loc) · 2.18 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
FROM python:3.11-slim-bookworm
LABEL maintainer="Mariano Ruiz <[email protected]>"
ENV CXXFLAGS="-mtune=intel -Os -pipe" \
PROCESS_TYPE="web" \
PORT=8000 \
NUM_WORKERS=3 \
NUM_THREADS=3 \
REQUEST_TIMEOUT=20
WORKDIR /usr/src/app
COPY requirements/requirements-dev.txt \
requirements/requirements-test.txt \
requirements/requirements-prod.txt \
/usr/src/app/
RUN buildDeps=' \
build-essential \
libuv1-dev \
libpq-dev \
libevent-dev \
libpcre3-dev \
zlib1g-dev \
libbz2-dev \
libxml2-dev \
' \
&& apt-get update -y \
&& apt-get install -y \
$buildDeps \
postgresql-client \
libpq5 \
libuv1 \
libpcre3 \
zlib1g \
libbz2-1.0 \
libxml2 \
gettext \
# adding "worker" user
&& useradd -ms /bin/bash worker \
&& chown -R worker:worker /usr/src/app \
&& mkdir /usr/tmp \
&& chown worker:worker /usr/tmp \
&& chown worker:worker requirements*.txt \
&& pip install --no-cache-dir -U pip \
&& pip3 install --no-cache-dir \
honcho \
&& pip3 install --no-cache-dir -r requirements-test.txt \
&& pip3 install --no-cache-dir -r requirements-dev.txt \
&& pip3 install --no-cache-dir -r requirements-prod.txt \
# cleanup
&& apt-get purge --auto-remove -yqq $buildDeps \
&& apt-get autoremove -yqq --purge \
&& apt-get clean \
&& rm -rf \
/var/lib/apt/lists/* \
/tmp/* \
/var/tmp/* \
/usr/share/man \
/usr/share/doc \
/usr/share/doc-base
COPY --chown=worker ./ ./
ARG BUILD
LABEL build=${BUILD}
RUN echo "Build: $BUILD" > image_build \
&& echo "UTC: $(date --utc +%FT%R)" >> image_build
# In a "prod" image, the migrations process should be executed
# before the image and kept on git or whatever VCS
RUN honcho start collectstatic compilemessages \
&& honcho start --no-prefix makemigrations \
&& rm *.sqlite3 *.log \
&& chown worker -R *
USER worker
HEALTHCHECK --interval=20s --timeout=3s \
CMD curl -f http://localhost:8000/health/?format=json || exit 1
CMD ["sh", "-c", "exec honcho start --no-prefix $PROCESS_TYPE"]