Spaces:
Sleeping
Sleeping
| # Stage 1: Build React frontend | |
| FROM node:20-slim AS frontend-build | |
| WORKDIR /app/frontend | |
| COPY frontend/package*.json ./ | |
| RUN npm install | |
| COPY frontend/ ./ | |
| RUN npm run build | |
| # Output: /app/frontend/dist | |
| # Stage 2: Python runtime | |
| FROM python:3.11-slim | |
| WORKDIR /app | |
| # HF Spaces runs containers as UID 1000 — create a non-root user | |
| RUN useradd -m -u 1000 appuser | |
| # Install uv | |
| COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ | |
| # Install Python dependencies via uv | |
| COPY pyproject.toml uv.lock ./ | |
| RUN uv sync --frozen --no-dev | |
| # Copy FastAPI backend | |
| COPY backend/ ./backend/ | |
| # Copy React static build from Stage 1 | |
| COPY --from=frontend-build /app/frontend/dist ./frontend/dist | |
| # Give appuser ownership | |
| RUN chown -R appuser:appuser /app | |
| USER appuser | |
| # HF Spaces requires port 7860 | |
| EXPOSE 7860 | |
| CMD ["uv", "run", "uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "7860"] | |