| # Stage 1: Build React | |
| FROM node:22 AS build-step | |
| WORKDIR /app/frontend | |
| COPY frontend/package*.json ./ | |
| RUN npm install --legacy-peer-deps | |
| COPY frontend/ ./ | |
| RUN npm run build | |
| # Stage 2: Python Backend | |
| FROM python:3.11-slim | |
| WORKDIR /app | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy the rest of the project files | |
| COPY . . | |
| COPY --from=build-step /app/frontend/dist /app/frontend/dist | |
| # Set environment variables | |
| ENV PYTHONPATH=/app | |
| ENV PYTHONUNBUFFERED=1 | |
| EXPOSE 7860 | |
| CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "7860"] |