-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
58 lines (46 loc) · 2.06 KB
/
Copy pathDockerfile
File metadata and controls
58 lines (46 loc) · 2.06 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
# Container image for local development, Kubernetes, and any container host.
#
# This is NOT what runs on Vercel — Vercel builds from api/index.py and
# requirements.txt directly. The two differ deliberately: this image installs
# requirements-local.txt as well, so the real cross-encoder reranker and the
# local embedding model are available. That is what makes benchmark configs D
# and E runnable at all.
FROM python:3.12-slim AS base
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1
WORKDIR /app
# curl is for the healthcheck; build-essential is needed by a few wheels that
# still compile on slim.
RUN apt-get update \
&& apt-get install -y --no-install-recommends curl build-essential \
&& rm -rf /var/lib/apt/lists/*
# ---------------------------------------------------------------------------
# Dependencies in their own layer so a source change does not reinstall torch.
# ---------------------------------------------------------------------------
COPY requirements.txt requirements-local.txt ./
ARG INCLUDE_LOCAL_MODELS=true
RUN pip install --upgrade pip \
&& if [ "$INCLUDE_LOCAL_MODELS" = "true" ]; then \
pip install -r requirements-local.txt; \
else \
pip install -r requirements.txt; \
fi
COPY . .
# Run as a non-root user. HF_HOME must be writable or the local embedder cannot
# download weights on first use.
RUN useradd --create-home --uid 10001 documind \
&& mkdir -p /home/documind/.cache/huggingface \
&& chown -R documind:documind /app /home/documind
USER documind
ENV HF_HOME=/home/documind/.cache/huggingface \
ENVIRONMENT=docker \
PORT=8000
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=5s --start-period=40s --retries=3 \
CMD curl -fsS "http://localhost:${PORT}/live" || exit 1
# Single worker by default: the process holds a database pool and, when the
# local models are installed, model weights in memory. Scale with replicas, not
# with workers.
CMD ["sh", "-c", "uvicorn app.main:app --host 0.0.0.0 --port ${PORT} --workers 1 --timeout-keep-alive 75"]