File size: 2,467 Bytes
17082a4
7df3afe
 
 
 
 
 
ae152b6
 
c38f7f8
17082a4
7df3afe
c38f7f8
7df3afe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
FROM python:3.10

# ── System deps ───────────────────────────────────────────────────────────────
RUN apt-get update && apt-get install -y --no-install-recommends \
    wget \
    curl \
    git \
    libgomp1 \
    libglib2.0-0 \
    libxcb1 \
    libgl1 \
    && rm -rf /var/lib/apt/lists/*
    
# ── Working directory ─────────────────────────────────────────────────────────
WORKDIR /app

# ── Python deps (cached layer β€” only re-runs when requirements.txt changes) ───
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip \
 && pip install --no-cache-dir -r requirements.txt

# ── App source ────────────────────────────────────────────────────────────────
COPY app.py .

# ── HF Spaces runs as a non-root user; make cache dirs writable ───────────────
RUN mkdir -p /app/.cache /app/tmp \
 && chmod -R 777 /app/.cache /app/tmp

# Tell HuggingFace / torch / transformers to use our writable cache dir
ENV HF_HOME=/app/.cache/huggingface
ENV TORCH_HOME=/app/.cache/torch
ENV TRANSFORMERS_CACHE=/app/.cache/huggingface/transformers
ENV TMPDIR=/app/tmp

# ── Port (HF Spaces expects 7860) ─────────────────────────────────────────────
EXPOSE 7860

# ── Launch β€” ALL server flags as explicit CLI args ────────────────────────────
# This is the only approach that cannot be silently overridden by HF's runner.
# config.toml is NOT used here so there is no ambiguity.
CMD ["streamlit", "run", "app.py", \
     "--server.headless=true", \
     "--server.port=7860", \
     "--server.address=0.0.0.0", \
     "--server.enableCORS=false", \
     "--server.enableXsrfProtection=false", \
     "--server.maxUploadSize=200", \
     "--server.fileWatcherType=none", \
     "--browser.gatherUsageStats=false", \
     "--theme.primaryColor=#6366f1", \
     "--theme.backgroundColor=#0a0e1a", \
     "--theme.secondaryBackgroundColor=#0f172a", \
     "--theme.textColor=#e2e8f0"]