# 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"]