DoclingAIO / Dockerfile
thethinkmachine's picture
Update Dockerfile
17082a4 verified
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"]