# ── KCC AgriAdvisor — HF Spaces Dockerfile ─────────────────────────────────── # Hugging Face Spaces: Docker SDK, CPU Basic (16GB RAM) # Port 7860 is mandatory for HF Spaces FROM python:3.10-slim # System deps RUN apt-get update && apt-get install -y build-essential curl git nodejs npm && rm -rf /var/lib/apt/lists/* WORKDIR /app # ── Python deps ─────────────────────────────────────────────────────────────── COPY requirements_hf.txt . RUN pip install --no-cache-dir -r requirements_hf.txt # ── Copy all project files ──────────────────────────────────────────────────── COPY . . # ── Build React frontend ────────────────────────────────────────────────────── RUN cd frontend && npm install && npm run build # Create static folder for serving built React RUN mkdir -p /app/static && cp -r /app/frontend/dist/* /app/static/ # ── HF Spaces runs as non-root user (uid 1000) ──────────────────────────────── RUN useradd -m -u 1000 appuser && chown -R appuser /app USER appuser # HF Spaces requires port 7860 EXPOSE 7860 # Start FastAPI — bm25 reassembly happens automatically at import time CMD ["uvicorn", "api:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]