| FROM python:3.11-slim | |
| ENV PYTHONDONTWRITEBYTECODE=1 \ | |
| PYTHONUNBUFFERED=1 \ | |
| TRANSFORMERS_NO_TF=1 \ | |
| USE_TF=0 \ | |
| TF_ENABLE_ONEDNN_OPTS=0 \ | |
| TRANSFORMERS_CACHE=/app/.cache/huggingface \ | |
| HF_HOME=/app/.cache/huggingface \ | |
| SENTENCE_TRANSFORMERS_HOME=/app/.cache/sentence-transformers | |
| WORKDIR /app | |
| RUN apt-get update \ | |
| && apt-get install -y --no-install-recommends build-essential git \ | |
| && rm -rf /var/lib/apt/lists/* | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir --upgrade pip \ | |
| && pip install --no-cache-dir -r requirements.txt | |
| # Create cache directories with proper permissions | |
| RUN mkdir -p /app/.cache/huggingface /app/.cache/sentence-transformers \ | |
| && chmod -R 777 /app/.cache | |
| # Pre-download embedding model to avoid runtime errors in HF Spaces | |
| RUN python -c "from sentence_transformers import SentenceTransformer; \ | |
| print('Downloading embedding model...'); \ | |
| model = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2'); \ | |
| print('Model cached successfully'); \ | |
| print(f'Model saved to: {model._model_card_vars.get(\"model_name\", \"unknown\")}')" | |
| COPY . . | |
| EXPOSE 7860 | |
| CMD ["uvicorn", "orchestrator:app", "--host", "0.0.0.0", "--port", "7860"] | |