# ---------------------------------------- # 1. Build Phase: Build Frontend React # ---------------------------------------- FROM node:20 AS frontend-builder WORKDIR /frontend COPY frontend/package*.json ./ RUN npm install COPY frontend/ ./ RUN npm run build # ---------------------------------------- # 2. Run Phase: Run FastAPI Python Server # ---------------------------------------- FROM python:3.10-slim WORKDIR /app # Install Python dependencies COPY backend/requirements.txt ./ RUN pip install --no-cache-dir -r requirements.txt # Copy Backend code COPY backend/ ./ # Copy built frontend assets to static folder in backend COPY --from=frontend-builder /frontend/dist ./static # Expose port for Hugging Face Spaces EXPOSE 7860 # Run FastAPI app CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]