Spaces:
Sleeping
Sleeping
| FROM python:3.11-slim | |
| WORKDIR /app | |
| ENV PYTHONUNBUFFERED=1 \ | |
| HF_HOME=/app/cache | |
| # CPU-only torch first (much smaller image than the default CUDA build) | |
| RUN pip install --no-cache-dir torch==2.5.1 --index-url https://download.pytorch.org/whl/cpu | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Bake the embedding model into the image → fast Space startup, no runtime download | |
| RUN python -c "from sentence_transformers import SentenceTransformer; \ | |
| SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')" | |
| COPY . . | |
| # HF Spaces runs containers as uid 1000 | |
| RUN useradd -m -u 1000 user && chown -R user:user /app | |
| USER user | |
| EXPOSE 7860 | |
| CMD ["gunicorn", "-b", "0.0.0.0:7860", "--workers", "1", "--threads", "4", "--timeout", "120", "app:app"] | |