Spaces:
Runtime error
Runtime error
| FROM python:3.11-slim | |
| # Set working directory | |
| WORKDIR /app | |
| # Install system dependencies | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| build-essential \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy requirements first (Docker layer caching) | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Pre-download sentence-transformer models during build | |
| # This avoids slow cold-start downloads at runtime | |
| RUN python -c "\ | |
| from sentence_transformers import SentenceTransformer, CrossEncoder; \ | |
| from transformers import AutoTokenizer, AutoModelForSequenceClassification; \ | |
| SentenceTransformer('all-MiniLM-L6-v2'); \ | |
| CrossEncoder('cross-encoder/ms-marco-MiniLM-L-6-v2'); \ | |
| model_name = 'cardiffnlp/twitter-roberta-base-sentiment-latest'; \ | |
| AutoTokenizer.from_pretrained(model_name); \ | |
| AutoModelForSequenceClassification.from_pretrained(model_name); \ | |
| import google.oauth2.id_token; \ | |
| import google.auth.transport.requests; \ | |
| import googleapiclient.discovery" | |
| # Copy application code | |
| COPY . . | |
| # Create data directories | |
| RUN mkdir -p data/chromadb | |
| # Default port (HF Spaces sets PORT=7860, local default is 8000) | |
| ENV PORT=7860 | |
| # Expose port | |
| EXPOSE ${PORT} | |
| # Start uvicorn with configurable port | |
| CMD uvicorn app.main:app --host 0.0.0.0 --port ${PORT} | |