Spaces:
Runtime error
Runtime error
File size: 1,292 Bytes
f3997d4 e814f43 f3997d4 e814f43 6fc5402 f3997d4 448c402 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | 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}
|