# ── Base ────────────────────────────────────────────────────────────────────── # SmolVLM is small enough to run on CPU, but a GPU Space is faster. # HuggingFace Spaces requires the app to 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 # ── Install Python deps ─────────────────────────────────────────────────────── COPY requirements.txt . RUN pip install --no-cache-dir --upgrade pip \ && pip install --no-cache-dir -r requirements.txt # ── Copy app source ─────────────────────────────────────────────────────────── COPY app.py . # ── HuggingFace cache (model weights downloaded at first startup) ───────────── ENV HF_HOME=/app/.cache/huggingface RUN mkdir -p /app/.cache/huggingface && chown -R appuser:appuser /app USER appuser # ── Port ────────────────────────────────────────────────────────────────────── EXPOSE 7860 # ── Start ───────────────────────────────────────────────────────────────────── CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]