forked from duke-crucible/snowballgr-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
54 lines (51 loc) · 1.44 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
FROM image-mirror-prod-registry.cloud.duke.edu/library/python:3.8.11-slim-buster AS base
WORKDIR /app
ENV \
# so logs are not buffered
PYTHONUNBUFFERED=1 \
PIP_DEFAULT_TIMEOUT=100 \
PIP_DISABLE_PIP_VERSION_CHECK=1
RUN pip install -U pip
FROM base AS build
RUN apt-get update && apt-get install -y \
gcc=4:8.3.0* \
libffi-dev
RUN pip install poetry==1.1.6
RUN python -m venv /venv
ENV PATH=/venv/bin:$PATH \
VIRTUAL_ENV=/venv
COPY pyproject.toml poetry.lock /app/
RUN poetry install --no-root --no-dev --no-interaction
COPY . /app
RUN poetry build --format wheel
FROM build AS dev
RUN poetry install
# Keep in sync with prod CMD
EXPOSE 8000
ENV FLASK_APP ./run.py
CMD [ "gunicorn", \
# See https://pythonspeed.com/articles/gunicorn-in-docker/ for worker settings.
"--worker-tmp-dir=/dev/shm", \
"--worker-class=gthread", \
"--bind=0.0.0.0:8000", \
"--timeout=1000", \
"--threads=4", \
"--workers=2", \
"run:app"]
FROM base AS prod
COPY --from=build /venv /venv
COPY --from=build /app/dist/*.whl /app/dist/
RUN /venv/bin/pip install --no-deps /app/dist/*.whl
COPY --from=build /app/run.py /app/
# Keep in sync with dev CMD
EXPOSE 8000
ENV FLASK_APP ./run.py
CMD [ "/venv/bin/gunicorn", \
# See https://pythonspeed.com/articles/gunicorn-in-docker/ for worker settings.
"--worker-tmp-dir=/dev/shm", \
"--worker-class=gthread", \
"--bind=0.0.0.0:8000", \
"--timeout=1000", \
"--threads=4", \
"--workers=2", \
"run:app"]