Spaces:
Sleeping
Sleeping
File size: 1,950 Bytes
00d3560 | 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 | # syntax=docker/dockerfile:1
# =============================================================================
# Placement Policy Advisor — single-container image.
# Corpus verification, model download, and vector indexing all run at BUILD time
# so the (ephemeral, free-tier) runtime filesystem already contains everything
# and the first request pays no download/indexing penalty.
# =============================================================================
FROM python:3.11-slim
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1
# onnxruntime (via FastEmbed) needs libgomp at runtime. Install as root first.
RUN apt-get update \
&& apt-get install -y --no-install-recommends libgomp1 \
&& rm -rf /var/lib/apt/lists/*
# --- Non-root user (UID 1000) ------------------------------------------------
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
WORKDIR /home/user/app
# --- Python dependencies (installed into the user site) ----------------------
COPY --chown=user:user requirements.txt ./
RUN pip install --user --upgrade pip \
&& pip install --user -r requirements.txt
# --- Application source ------------------------------------------------------
COPY --chown=user:user . ./
# --- Build-time data preparation ---------------------------------------------
# 1) verify curated Contextmd/ against source PDFs (quality gate),
# 2) cache embedding model + init Qdrant,
# 3) chunk Contextmd/ + embed + upsert into the local Qdrant collection.
RUN python convert_docs.py \
&& python download_models.py \
&& python data_indexer.py
# --- Networking --------------------------------------------------------------
# APP_PORT is read from the environment at runtime by main.py; this ARG/ENV pair
# only provides the concrete value EXPOSE requires and a sensible default.
ARG APP_PORT=7860
ENV APP_PORT=${APP_PORT}
EXPOSE ${APP_PORT}
CMD ["python", "main.py"]
|