| # Stage 1: Build the React frontend | |
| FROM node:18-slim AS frontend-builder | |
| WORKDIR /frontend | |
| COPY frontend/package.json ./ | |
| RUN npm install | |
| COPY frontend/ ./ | |
| RUN npm run build | |
| # Stage 2: Serve via FastAPI backend | |
| FROM python:3.11-slim | |
| WORKDIR /app | |
| # Install backend dependencies | |
| COPY backend/requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy backend source code | |
| COPY backend/ . | |
| # Copy static frontend bundle from Stage 1 into the "static" folder | |
| COPY --from=frontend-builder /frontend/dist ./static | |
| # Expose port 7860 (Hugging Face Spaces default port) | |
| EXPOSE 7860 | |
| # Run uvicorn on port 7860 | |
| CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"] | |