-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
62 lines (48 loc) · 1.75 KB
/
Dockerfile
File metadata and controls
62 lines (48 loc) · 1.75 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
###########################################################
# Builder stage. Build dependencies.
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim AS builder
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
UV_COMPILE_BYTECODE=1 \
UV_LINK_MODE=copy \
UV_PYTHON_DOWNLOADS=0
# pycups is sources-only so we have to build it
RUN apt-get update && apt-get install -y --no-install-recommends libcups2-dev gcc && 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.12-slim-bookworm AS production
ENV PYTHONUNBUFFERED=1
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
libcups2 \
cups-client \
libturbojpeg0 \
exiftool \
ffmpeg \
libheif-dev \
&& rm -rf /var/lib/apt/lists/*
# Copy the applicant from the builder
COPY --from=builder /app /app
# Fonts directory, onnx models directory
RUN chmod -R 777 /app/.venv/lib/python3.*/site-packages/capybara/vision/visualization/ /app/.venv/lib/python3.*/site-packages/docaligner/heatmap_reg/ckpt/
# 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=*" \
]