# ── Base ────────────────────────────────────────────────────────────────────── # SmolVLM-500M is lightweight enough for a free CPU Space on HuggingFace. # App must listen on port 7860. FROM python:3.11-slim # ── System deps ─────────────────────────────────────────────────────────────── RUN apt-get update && apt-get install -y --no-install-recommends \ git \ libgl1 \ libglib2.0-0 \ && rm -rf /var/lib/apt/lists/* # ── Non-root user (HF Spaces runs as UID 1000) ──────────────────────────────── RUN useradd -m -u 1000 appuser WORKDIR /app # ── Python deps ─────────────────────────────────────────────────────────────── COPY requirements.txt . RUN pip install --no-cache-dir --upgrade pip \ && pip install --no-cache-dir -r requirements.txt # ── App source ──────────────────────────────────────────────────────────────── COPY app.py . # ── HuggingFace model cache ─────────────────────────────────────────────────── ENV HF_HOME=/app/.cache/huggingface RUN mkdir -p /app/.cache/huggingface && chown -R appuser:appuser /app USER appuser EXPOSE 7860 CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]