Spaces:
Sleeping
Sleeping
| # Multi-stage build for Hugging Face Spaces | |
| FROM node:18-alpine AS frontend-builder | |
| WORKDIR /app/frontend | |
| # Copy frontend files | |
| COPY frontend/package*.json ./ | |
| RUN npm ci | |
| COPY frontend/ ./ | |
| RUN npm run build | |
| # Python backend stage | |
| FROM python:3.11-slim | |
| WORKDIR /app | |
| # Install system dependencies (including Python dev headers and swig for pymupdf) | |
| RUN apt-get update && apt-get install -y \ | |
| build-essential \ | |
| python3-dev \ | |
| swig \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy requirements and install Python dependencies | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy backend code | |
| COPY backend1/ ./backend1/ | |
| COPY ap_agent1/ ./ap_agent1/ | |
| # Create data directory (app will create suppliers.csv at runtime if needed) | |
| # The app's ensure_default_suppliers() function creates suppliers.csv automatically | |
| RUN mkdir -p data | |
| # Note: suppliers.csv is optional - the app creates a default one if missing | |
| # If you want to use a custom suppliers.csv, upload it to your Space and it will be used | |
| # Copy built frontend from builder stage | |
| COPY --from=frontend-builder /app/frontend/dist ./frontend/dist | |
| # Expose port (Hugging Face Spaces uses port 7860 by default) | |
| EXPOSE 7860 | |
| # Set environment variables | |
| ENV PYTHONUNBUFFERED=1 | |
| ENV PORT=7860 | |
| # Run the FastAPI app | |
| CMD ["python", "-m", "uvicorn", "backend1.main:app", "--host", "0.0.0.0", "--port", "7860"] | |