Spaces:
Sleeping
Sleeping
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"]
|