Spaces:
Runtime error
Runtime error
| # ============================================================================= | |
| # Mozhii RAG Data Platform - Dockerfile | |
| # ============================================================================= | |
| # Compatible with: | |
| # - HuggingFace Spaces (Docker SDK) β port 7860, non-root uid 1000 | |
| # - fly.io β set PORT=8080 in fly.toml env | |
| # - Render β set PORT=10000 via env | |
| # ============================================================================= | |
| FROM python:3.11-slim | |
| # ββ System packages βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| curl \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # ββ Non-root user (required by HuggingFace Spaces) βββββββββββββββββββββββββββ | |
| # HF Spaces runs containers as uid=1000. Creating the user explicitly lets us | |
| # set correct ownership on the data directory. | |
| RUN useradd -m -u 1000 appuser | |
| # ββ Working directory βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| WORKDIR /app | |
| # ββ Python dependencies βββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt gunicorn==21.2.0 | |
| # ββ Application source ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| COPY . . | |
| # ββ Persistent data directories βββββββββββββββββββββββββββββββββββββββββββββββ | |
| # Create full directory tree and give ownership to appuser. | |
| RUN mkdir -p \ | |
| data/pending/raw \ | |
| data/pending/cleaned \ | |
| data/pending/chunked/_locks \ | |
| data/approved/raw \ | |
| data/approved/cleaned \ | |
| data/approved/chunked \ | |
| && chown -R appuser:appuser /app | |
| # ββ Switch to non-root user βββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| USER appuser | |
| # ββ Runtime configuration βββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| # HuggingFace Spaces requires port 7860. | |
| # Override with PORT env var for fly.io (8080) or Render (10000). | |
| ENV PORT=7860 | |
| EXPOSE 7860 | |
| # ββ Health check ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| HEALTHCHECK --interval=30s --timeout=10s --start-period=15s --retries=3 \ | |
| CMD curl -f http://localhost:${PORT}/ || exit 1 | |
| # ββ Start command βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| CMD ["gunicorn", "app:create_app()", "-c", "gunicorn_config.py"] | |