Spaces:
Sleeping
Sleeping
File size: 889 Bytes
7910b95 c7cbbed 7910b95 c7cbbed 7910b95 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | # 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"]
|