Spaces:
Runtime error
Runtime error
| # ---------- Stage 1: Build React Frontend ---------- | |
| FROM node:18-bullseye AS frontend-builder | |
| WORKDIR /frontend | |
| # Copy package.json only (no package-lock.json required) | |
| COPY frontend/package.json ./ | |
| RUN npm install --legacy-peer-deps | |
| # Copy rest of frontend and build | |
| COPY frontend/ ./ | |
| RUN npm run build | |
| # ---------- Stage 2: Python Backend ---------- | |
| FROM python:3.10-slim AS backend | |
| WORKDIR /app | |
| # Install system dependencies for OCR, Earth Engine, FAISS, OpenCV, PDF | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| build-essential tesseract-ocr libgl1 libsndfile1 poppler-utils \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy backend files | |
| COPY backend/ ./backend/ | |
| COPY backend/requirements.txt . | |
| # Install Python deps | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy model + FAISS db | |
| COPY soil_best_model.pth ./soil_best_model.pth | |
| COPY faiss_books_db.zip ./faiss_books_db.zip | |
| # Copy React build from stage 1 | |
| COPY --from=frontend-builder /frontend/build ./frontend/build | |
| # Expose port | |
| EXPOSE 7860 | |
| # Run FastAPI backend | |
| CMD ["uvicorn", "backend.app.main:app", "--host", "0.0.0.0", "--port", "7860"] |