File size: 2,238 Bytes
406e5bf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# ── 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"]