Spaces:
Sleeping
Sleeping
File size: 1,962 Bytes
afca779 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | # 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"]
|