-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
59 lines (46 loc) · 1.49 KB
/
Dockerfile
File metadata and controls
59 lines (46 loc) · 1.49 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
###########################################################
# Builder stage. Build dependencies.
FROM ghcr.io/astral-sh/uv:python3.14-bookworm-slim AS builder
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
UV_COMPILE_BYTECODE=1 \
UV_LINK_MODE=copy \
UV_PYTHON_DOWNLOADS=0
RUN apt-get update \
&& apt-get install --no-install-recommends -y \
build-essential \
libmagic1 \
libvips-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY ./pyproject.toml ./uv.lock ./
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-install-project --no-dev
###########################################################
# Production stage. Copy only runtime deps that were installed in the Builder stage.
FROM python:3.14-slim-bookworm AS production
ENV PYTHONUNBUFFERED=1
RUN apt-get update \
&& apt-get install --no-install-recommends -y \
libmagic1 \
libvips-dev \
&& rm -rf /var/lib/apt/lists/*
# Copy the applicant from the builder
COPY --from=builder /app /app
# Create user with the name uv
RUN groupadd -g 1500 uv && \
useradd -m -u 1500 -g uv uv
USER uv
WORKDIR /app
# Place executables in the environment at the front of the path
ENV PATH="/app/.venv/bin:$PATH"
COPY --chown=uv:uv . /app
EXPOSE 8000
CMD ["gunicorn", \
"--worker-class", "uvicorn.workers.UvicornWorker", \
"--bind", "0.0.0.0:8000", \
"--workers", "1", \
"src.api.app:app", \
"--timeout", "300", \
"--forwarded-allow-ips=*" \
]