# ------------------------------------ # STAGE 1: Build the React Frontend # ------------------------------------ FROM node:20-slim AS frontend-build WORKDIR /app/frontend # Copy the frontend dependencies definition COPY package*.json ./ # Install dependencies RUN npm ci # Copy all the frontend source files COPY index.html main.jsx vite.config.js eslint.config.js ./ COPY public ./public COPY src ./src # Build the React application RUN npm run build # ------------------------------------ # STAGE 2: Build the FastAPI Backend # ------------------------------------ FROM python:3.11-slim WORKDIR /app # Install system dependencies # Tesseract OCR is needed for the pytesseract library you are using RUN apt-get update && apt-get install -y \ tesseract-ocr \ libtesseract-dev \ && rm -rf /var/lib/apt/lists/* # Copy backend requirements and install Python dependencies COPY Agent_Backend/requirements.txt ./Agent_Backend/ RUN pip install --no-cache-dir -r Agent_Backend/requirements.txt # Copy the backend code into the container COPY Agent_Backend/ ./Agent_Backend/ # Copy the compiled frontend build from the first stage COPY --from=frontend-build /app/frontend/dist ./Agent_Frontend/dist # Expose port 7860 which is the port Hugging Face Spaces expects EXPOSE 7860 # Run the FastAPI server via Uvicorn on port 7860 CMD ["uvicorn", "Agent_Backend.main:app", "--host", "0.0.0.0", "--port", "7860"]