Spaces:
Runtime error
Runtime error
File size: 1,775 Bytes
4d7cfb5 | 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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | # ExamInsight - Hugging Face Spaces Docker Deployment
# Multi-stage build for React frontend + FastAPI backend
# =============================================================================
# Stage 1: Build React Frontend
# =============================================================================
FROM node:20-slim AS frontend-builder
WORKDIR /app/frontend
# Copy package files
COPY chatkit/frontend/package*.json ./
# Install dependencies
RUN npm ci --legacy-peer-deps
# Copy source files
COPY chatkit/frontend/ ./
# Build for production (output to dist/)
RUN npm run build
# =============================================================================
# Stage 2: Python Backend + Serve Frontend
# =============================================================================
FROM python:3.11-slim
# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
# Create non-root user for HF Spaces
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user
ENV PATH=/home/user/.local/bin:$PATH
WORKDIR $HOME/app
# Install Python dependencies
COPY --chown=user chatkit/backend/pyproject.toml ./
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir .
# Copy backend code
COPY --chown=user chatkit/backend/app ./app
# Copy report template
COPY --chown=user report-template.html ./
# Copy built frontend from Stage 1
COPY --from=frontend-builder --chown=user /app/frontend/dist ./static
# Expose port (HF Spaces uses 7860)
EXPOSE 7860
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:7860/health')"
# Run the server
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|