-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgunicorn.Dockerfile
More file actions
69 lines (53 loc) · 1.92 KB
/
Copy pathgunicorn.Dockerfile
File metadata and controls
69 lines (53 loc) · 1.92 KB
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
FROM ghcr.io/astral-sh/uv:0.9.11 AS uv-base
###########
# Runtime #
###########
FROM python:3.14.2-alpine as build
ENV UV_SYSTEM_PYTHON=1 \
UV_LINK_MODE=copy \
UV_COMPILE_BYTECODE=1 \
PATH="/app/.venv/bin:$PATH"
COPY --from=uv-base /uv /bin/
# Change the working directory to the `app` directory
WORKDIR /app
RUN set -ex \
&& apk add --no-cache \
build-base \
gcc \
linux-headers \
libev-dev \
musl-dev \
python3-dev
# Install dependencies
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --locked --no-install-project --no-editable --group=gunicorn
###########
# Runtime #
###########
FROM python:3.14.2-alpine 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."
ENV UV_SYSTEM_PYTHON=1 \
UV_LINK_MODE=copy \
UV_COMPILE_BYTECODE=1 \
PATH="/app/.venv/bin:$PATH"
EXPOSE 8000
COPY --from=uv-base /uv /bin/
# Change the working directory to the `app` directory
WORKDIR /app
# Copy built dependencies
COPY --from=build /app/.venv/ /app/.venv/
ADD src/ /app
# Sync the project
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --locked --no-editable --group=gunicorn
# Run Gunicorm
CMD ["gunicorn", "--bind", "0.0.0.0:8000", "--workers", "1", "wsgi:app"]