# Use an official lightweight Python base image FROM python:3.10 # Set working directory inside container WORKDIR /app # Copy requirements first (for caching layers) COPY requirements.txt . # Install system dependencies (for lxml, spacy, etc.) RUN apt-get update && apt-get install -y \ build-essential \ python3-dev \ libxml2-dev \ libxslt-dev \ && rm -rf /var/lib/apt/lists/* # Install Python dependencies RUN pip install --no-cache-dir -r requirements.txt # Copy the rest of the app COPY . . # --- Hugging Face cache fix --- # Make a dedicated cache directory with proper permissions RUN mkdir -p /app/hf_cache && chmod -R 777 /app/hf_cache ENV HF_HOME=/app/hf_cache ENV TRANSFORMERS_CACHE=/app/hf_cache ENV HF_DATASETS_CACHE=/app/hf_cache # Expose port (HF Spaces expects 7860 usually) EXPOSE 7860 # Run your FastAPI app via python module CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]