-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
41 lines (32 loc) · 1.42 KB
/
Copy pathDockerfile
File metadata and controls
41 lines (32 loc) · 1.42 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
FROM python:3.14-slim
COPY --from=ghcr.io/astral-sh/uv:0.11.6 /uv /uvx /bin/
ENV UV_COMPILE_BYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV PYTHONPATH=/app
ENV PATH="/app/.venv/bin:$PATH"
WORKDIR /app
COPY pyproject.toml uv.lock README.md ./
RUN uv sync --frozen --no-dev
COPY app ./app
RUN useradd -m screening-user
USER screening-user
# Warm the model caches into the image before HF_HUB_OFFLINE is set below;
# otherwise the first real request fails offline. Constructing the guardrail is
# enough: the only things that download are spaCy's en_core_web_sm and the
# injection classifier, and both load in `ClassifierGuardrail.__init__`.
#
# Deliberately NOT a real `.scrub()` any more. Article 9 detection is now an
# HTTP call to the Gemma endpoint (LLMGuardrailRecognizer), which does not exist
# at build time, and that recognizer fails closed on purpose — so a scrub here
# would abort the build. GLiNER, whose lazy loading was the original reason for
# running a scrub, is gone.
#
# SCREENING_SERVICE_API_KEY is a build-only placeholder passed to this one
# command (not an ENV, so it is never baked into the image): guard_classifier
# now imports app.config transitively, and Settings refuses to construct without
# a key.
RUN SCREENING_SERVICE_API_KEY=build-warmup-not-a-real-secret \
python -c "from app.adapters.guard_classifier import ClassifierGuardrail; ClassifierGuardrail()"
EXPOSE 8000
ENV HF_HUB_OFFLINE=1
CMD ["fastapi", "run"]