Spaces:
Sleeping
Sleeping
| # ════════════════════════════════════════════════════════════════════════════ | |
| # EcomQA — Dockerfile | |
| # Fix #7: Model weights baked in at build time → zero cold-start at runtime | |
| # ════════════════════════════════════════════════════════════════════════════ | |
| FROM python:3.11-slim AS base | |
| # System deps for Playwright + PyTorch | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| gcc g++ libffi-dev curl git \ | |
| # Chromium runtime dependencies | |
| libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 \ | |
| libxkbcommon0 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 \ | |
| libgbm1 libasound2 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| WORKDIR /app | |
| # ── Install Python dependencies ─────────────────────────────────────────────── | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # ── Install Playwright browser (baked in) ──────────────────────────────────── | |
| RUN playwright install chromium --with-deps | |
| # ── Pre-download all HuggingFace model weights (Fix #7) ────────────────────── | |
| # This runs during image build so the container starts instantly. | |
| COPY scripts/download_models.py scripts/ | |
| RUN python scripts/download_models.py --skip-playwright | |
| # ── Copy application source ──────────────────────────────────────────────────── | |
| COPY . . | |
| # ── Create data directory for SQLite ───────────────────────────────────────── | |
| RUN mkdir -p data | |
| # ── Environment ─────────────────────────────────────────────────────────────── | |
| ENV PYTHONPATH=/app | |
| ENV PYTHONUNBUFFERED=1 | |
| ENV TRANSFORMERS_CACHE=/app/.hf_cache | |
| ENV HF_HOME=/app/.hf_cache | |
| EXPOSE 7860 | |
| # ── Healthcheck ─────────────────────────────────────────────────────────────── | |
| HEALTHCHECK --interval=30s --timeout=10s --start-period=60s \ | |
| CMD curl -f http://localhost:7860/ || exit 1 | |
| # ── Start ───────────────────────────────────────────────────────────────────── | |
| CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "1", "--timeout", "300", "src.app:app"] | |