# Use official lightweight Python image FROM python:3.11-slim # Set working directory WORKDIR /app # Avoid interactive prompts during package installs ENV DEBIAN_FRONTEND=noninteractive # Set Hugging Face cache directories to writable paths ENV TRANSFORMERS_CACHE=/tmp/transformers_cache \ HF_HOME=/tmp/hf_home \ HF_DATASETS_CACHE=/tmp/hf_datasets_cache \ HF_METRICS_CACHE=/tmp/hf_metrics_cache # Install system dependencies (git, wget, etc.) RUN apt-get update && apt-get install -y --no-install-recommends \ git \ curl \ build-essential \ && rm -rf /var/lib/apt/lists/* # Copy requirements and app code COPY requirements.txt . COPY app.py . # Install Python dependencies RUN pip install --upgrade pip \ && pip install --no-cache-dir -r requirements.txt # Expose the default port for Hugging Face Spaces EXPOSE 7860 # Launch FastAPI app with uvicorn CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]