# HF Spaces requires a non-root user with UID 1000 FROM python:3.11-slim RUN useradd -m -u 1000 user USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH WORKDIR /app # Install dependencies before copying source for better layer caching COPY --chown=user requirements.txt . RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir -r requirements.txt # Bake the embedding model into the image so there is no download on cold start RUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('all-MiniLM-L6-v2')" # Copy application source (data.json is excluded via .dockerignore) COPY --chown=user . . # Seed data.json with the 16 sample documents RUN python demo.py # HF Spaces expects the app on port 7860 EXPOSE 7860 ENV PORT=7860 CMD ["python", "app.py"]