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