Spaces:
Sleeping
Sleeping
| # Hugging Face Spaces β Docker deployment | |
| # Builds React frontend, then runs Flask backend which serves everything. | |
| # HF Spaces expects the app on port 7860. | |
| FROM python:3.11-slim | |
| # ββ System deps ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| curl \ | |
| nodejs \ | |
| npm \ | |
| && rm -rf /var/lib/apt/lists/* | |
| WORKDIR /app | |
| # ββ Python dependencies βββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # ββ Build React frontend ββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| COPY frontend/package.json frontend/package-lock.json* ./frontend/ | |
| RUN cd frontend && npm install | |
| COPY frontend/ ./frontend/ | |
| RUN cd frontend && npm run build | |
| # ββ Backend source + trained model βββββββββββββββββββββββββββββββββββββββββββ | |
| COPY app.py classifier.py feature_extraction.py language_config.py ./ | |
| COPY model/ ./model/ | |
| # ββ Runtime config ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| ENV PORT=7860 | |
| EXPOSE 7860 | |
| # Single worker because the sklearn model is not thread-safe during load; | |
| # increase --workers if you switch to a thread-safe serving strategy. | |
| CMD ["gunicorn", \ | |
| "--bind", "0.0.0.0:7860", \ | |
| "--timeout", "300", \ | |
| "--workers", "1", \ | |
| "--threads", "4", \ | |
| "app:app"] | |