# Build Stage: Frontend FROM node:20-slim AS frontend-builder WORKDIR /app/frontend COPY frontend/package*.json ./ RUN npm install COPY frontend/ . RUN npm run build # Final Stage: Backend + Static Frontend FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim # Create a non-root user (HF Spaces requirement for some features/security) RUN useradd -m -u 1000 user USER user ENV PATH="/home/user/.local/bin:$PATH" WORKDIR /app # Install system dependencies (requires root) USER root RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ && rm -rf /var/lib/apt/lists/* USER user # Copy backend dependency files COPY --chown=user pyproject.toml uv.lock ./ # Install dependencies RUN uv sync --frozen # Copy the rest of the backend code COPY --chown=user . . # Copy built frontend from the builder stage COPY --from=frontend-builder --chown=user /app/frontend/dist ./frontend/dist # Expose the default HF Spaces port EXPOSE 7860 # Set environment variables for HF ENV HOST=0.0.0.0 ENV PORT=7860 # Run the application CMD ["uv", "run", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]