Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
24 lines (22 loc) · 1.38 KB
/
Copy pathDockerfile
File metadata and controls
24 lines (22 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
FROM python:3.12.11-slim-bookworm AS builder
ENV PIP_DISABLE_PIP_VERSION_CHECK=1 PIP_NO_CACHE_DIR=1
WORKDIR /build
COPY pyproject.toml README.md ./
COPY src ./src
RUN python -m pip wheel --wheel-dir /wheels ".[ingest]"
FROM python:3.12.11-slim-bookworm AS runtime
ENV PYTHONUNBUFFERED=1 PYTHONDONTWRITEBYTECODE=1
RUN groupadd --gid 10001 fastrag && useradd --uid 10001 --gid fastrag --create-home fastrag
COPY --from=builder /wheels /wheels
RUN python -m pip install --no-index --find-links=/wheels fastrag && rm -r /wheels
WORKDIR /app
COPY --chown=fastrag:fastrag config ./config
# In-process models are fetched at boot rather than baked in: they are gigabytes, and
# `download_models` checksum-verifies whichever pair the environment pins.
RUN mkdir -p /models && chown fastrag:fastrag /models
USER fastrag
EXPOSE 8000
# calibration.json is gitignored, so COPY config/ only brings the prompt. Materialize
# it from FASTRAG_CALIBRATION_JSON when that env var is set (Render / any Docker host).
# FASTRAG_DOWNLOAD_MODELS=true fetches the pinned in-process models before serving.
CMD ["sh", "-c", "if [ -n \"$FASTRAG_CALIBRATION_JSON\" ]; then printf '%s\\n' \"$FASTRAG_CALIBRATION_JSON\" > /app/config/calibration.json; fi; if [ \"$FASTRAG_DOWNLOAD_MODELS\" = true ]; then python -m fastrag.download_models || exit 1; fi; exec uvicorn fastrag.api:app --host 0.0.0.0 --port ${PORT:-8000} --proxy-headers"]