-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgunicorn.Dockerfile
67 lines (50 loc) · 1.8 KB
/
gunicorn.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
####################
### Build / Wheels #
####################
FROM python:3.12.0-alpine3.17 as requirements
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
# pip
PIP_DISABLE_PIP_VERSION_CHECK=on \
# poetry
POETRY_HOME=/opt/poetry \
POETRY_NO_INTERACTION=1
RUN set -ex \
&& pip install poetry
WORKDIR /tmp
COPY pyproject.toml poetry.lock /tmp/
RUN set -ex \
&& poetry export --with=gunicorn -f requirements.txt --output requirements.txt \
&& pip wheel --no-cache-dir \
--wheel-dir /wheels \
--requirement requirements.txt
###############
# Development #
###############
FROM requirements as development
RUN set -ex \
&& poetry config virtualenvs.options.system-site-packages true \
&& poetry config virtualenvs.create false \
&& poetry install --no-root --no-interaction --no-ansi --without=dev --with=gunicorn
WORKDIR /build/src
COPY ./src /build/src/
# Gunicorm
CMD ["gunicorn", "--bind", "0.0.0.0:8000", "--workers", "1", "wsgi:app"]
###########
# Runtime #
###########
FROM python:3.12.0-alpine3.17 as runtime
LABEL "org.opencontainers.image.authors"="Marc-Aurele BRothier"
LABEL "org.opencontainers.image.url"="https://github.com/marcaurele/flask-servers-testing"
LABEL "org.opencontainers.image.source"="https://github.com/marcaurele/flask-servers-testing/blob/main/Dockerfile"
LABEL "org.opencontainers.image.vendor"="Private"
LABEL "org.opencontainers.image.title"="Flask servers testing"
LABEL "org.opencontainers.image.description"="Image to validate performance for different WSGI and ASGI servers."
COPY --from=requirements /wheels/ /wheels/
RUN set -ex \
&& python -m pip install --no-cache-dir --no-index /wheels/* \
&& rm -rf /wheels
WORKDIR /app
COPY ./src /app
# Gunicorm
CMD ["gunicorn", "--bind", "0.0.0.0:8000", "--workers", "1", "wsgi:app"]