Spaces:
Sleeping
Sleeping
FROM python:3.10-slim | |
# Install dependencies | |
RUN apt-get update && apt-get install -y git curl && rm -rf /var/lib/apt/lists/* | |
# Set working directory | |
WORKDIR /app | |
# Create a local cache dir for HuggingFace models | |
ENV TRANSFORMERS_CACHE=/app/.cache/huggingface | |
ENV HF_HOME=/app/.cache/huggingface | |
# Copy source files | |
COPY . /app | |
# Install Python packages | |
RUN pip install --no-cache-dir --upgrade pip | |
RUN pip install --no-cache-dir -r requirements.txt | |
# Preload model into cache | |
RUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('all-MiniLM-L6-v2')" | |
# Expose port for Hugging Face Spaces | |
ENV PORT 7860 | |
# Launch FastAPI with Uvicorn | |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"] | |