This repository has been archived by the owner on Jun 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Dockerfile
59 lines (44 loc) · 1.58 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
# ---
# --- Builder image
# ---
FROM python:3.10-alpine as builder
# Install build dependancies
RUN apk update && apk add --upgrade --no-cache g++ make
# Install pipenv
RUN pip install --no-cache-dir --upgrade pip
RUN pip install pipenv
WORKDIR /usr/local/src
# Build a venv with dependancies in current directory
COPY Pipfile.lock Pipfile* /usr/local/src/
RUN PIPENV_VENV_IN_PROJECT=1 pipenv sync
# ---
# --- Application image
# ---
FROM python:3.10-alpine as runtime
# Create the user idunn
RUN addgroup --gid 1000 idunn
RUN adduser --disabled-password --home /home/idunn --ingroup idunn \
--uid 1000 idunn
ENV PYTHONUNBUFFERED=1
# Set the multiprocess mode for gunicorn
ENV IDUNN_PROMETHEUS_MULTIPROC=1
ENV PROMETHEUS_MULTIPROC_DIR=/home/idunn/prometheus_multiproc
# Install lib dependancies
RUN apk update && apk add --upgrade --no-cache geos
USER idunn
WORKDIR /home/idunn
RUN mkdir -p /home/idunn/prometheus_multiproc
# Add files into images
COPY app.py /home/idunn
COPY idunn /home/idunn/idunn
COPY --from=builder /usr/local/src/.venv /home/idunn/.venv
EXPOSE 5000
# You can set the number of workers by passing --workers=${NB_WORKER} to the docker run command.
# For some reason, an array is required here to accept other params on run.
ENTRYPOINT [ \
"./.venv/bin/python", "-m", "gunicorn", "app:app", \
"--bind=0.0.0.0:5000", \
"--pid=/tmp/gunicorn.pid", \
"-k", "uvicorn.workers.UvicornWorker", \
"--preload" \
]