Spaces:
Build error
Build error
| # Multi-stage Dockerfile for Hugging Face Spaces | |
| # Single container: FastAPI serves React static files directly | |
| # Stage 1: Build React frontend | |
| FROM node:20-alpine AS frontend-build | |
| WORKDIR /frontend | |
| COPY frontend/package*.json ./ | |
| RUN npm ci | |
| COPY frontend/ ./ | |
| RUN npm run build | |
| # Stage 2: Python + FastAPI | |
| FROM python:3.11-slim | |
| WORKDIR /app | |
| # Install system dependencies (gcc needed for some Python packages) | |
| RUN apt-get update && apt-get install -y \ | |
| gcc \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy and install Python dependencies | |
| COPY backend/requirements.txt ./requirements.txt | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy backend code | |
| COPY backend ./backend | |
| # Copy built frontend from Node stage (Vite outputs to dist/) | |
| COPY --from=frontend-build /frontend/dist ./frontend/dist | |
| # Create data directory for SQLite database | |
| RUN mkdir -p /app/data | |
| # Hugging Face Spaces expects port 7860 | |
| EXPOSE 7860 | |
| # Environment variables | |
| ENV PORT=7860 | |
| ENV PYTHONUNBUFFERED=1 | |
| # Start FastAPI with Uvicorn | |
| CMD ["uvicorn", "backend.app.main:app", "--host", "0.0.0.0", "--port", "7860"] | |