FROM pytorch/pytorch:2.5.1-cuda12.1-cudnn9-runtime # System deps RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential git curl ca-certificates \ && rm -rf /var/lib/apt/lists/* WORKDIR /app # HF cache — writable directory inside container ENV HF_HOME=/app/.cache/huggingface \ TRANSFORMERS_CACHE=/app/.cache/huggingface \ HF_HUB_ENABLE_HF_TRANSFER=1 \ PYTHONUNBUFFERED=1 COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Pre-create HF cache dir (HF Spaces are read-only by default; this is writable) RUN mkdir -p /app/.cache/huggingface && chmod -R 777 /app/.cache COPY app.py . EXPOSE 7860 CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]