Spaces:
Runtime error
Runtime error
chih.yikuan commited on
Commit ·
4d7cfb5
1
Parent(s): a9ffafc
Fix: Change SDK from static to docker and add Dockerfile at root
Browse files- Dockerfile +62 -0
- README.md +1 -2
Dockerfile
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ExamInsight - Hugging Face Spaces Docker Deployment
|
| 2 |
+
# Multi-stage build for React frontend + FastAPI backend
|
| 3 |
+
|
| 4 |
+
# =============================================================================
|
| 5 |
+
# Stage 1: Build React Frontend
|
| 6 |
+
# =============================================================================
|
| 7 |
+
FROM node:20-slim AS frontend-builder
|
| 8 |
+
|
| 9 |
+
WORKDIR /app/frontend
|
| 10 |
+
|
| 11 |
+
# Copy package files
|
| 12 |
+
COPY chatkit/frontend/package*.json ./
|
| 13 |
+
|
| 14 |
+
# Install dependencies
|
| 15 |
+
RUN npm ci --legacy-peer-deps
|
| 16 |
+
|
| 17 |
+
# Copy source files
|
| 18 |
+
COPY chatkit/frontend/ ./
|
| 19 |
+
|
| 20 |
+
# Build for production (output to dist/)
|
| 21 |
+
RUN npm run build
|
| 22 |
+
|
| 23 |
+
# =============================================================================
|
| 24 |
+
# Stage 2: Python Backend + Serve Frontend
|
| 25 |
+
# =============================================================================
|
| 26 |
+
FROM python:3.11-slim
|
| 27 |
+
|
| 28 |
+
# Set environment variables
|
| 29 |
+
ENV PYTHONUNBUFFERED=1
|
| 30 |
+
ENV PYTHONDONTWRITEBYTECODE=1
|
| 31 |
+
|
| 32 |
+
# Create non-root user for HF Spaces
|
| 33 |
+
RUN useradd -m -u 1000 user
|
| 34 |
+
USER user
|
| 35 |
+
ENV HOME=/home/user
|
| 36 |
+
ENV PATH=/home/user/.local/bin:$PATH
|
| 37 |
+
|
| 38 |
+
WORKDIR $HOME/app
|
| 39 |
+
|
| 40 |
+
# Install Python dependencies
|
| 41 |
+
COPY --chown=user chatkit/backend/pyproject.toml ./
|
| 42 |
+
RUN pip install --no-cache-dir --upgrade pip && \
|
| 43 |
+
pip install --no-cache-dir .
|
| 44 |
+
|
| 45 |
+
# Copy backend code
|
| 46 |
+
COPY --chown=user chatkit/backend/app ./app
|
| 47 |
+
|
| 48 |
+
# Copy report template
|
| 49 |
+
COPY --chown=user report-template.html ./
|
| 50 |
+
|
| 51 |
+
# Copy built frontend from Stage 1
|
| 52 |
+
COPY --from=frontend-builder --chown=user /app/frontend/dist ./static
|
| 53 |
+
|
| 54 |
+
# Expose port (HF Spaces uses 7860)
|
| 55 |
+
EXPOSE 7860
|
| 56 |
+
|
| 57 |
+
# Health check
|
| 58 |
+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
| 59 |
+
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:7860/health')"
|
| 60 |
+
|
| 61 |
+
# Run the server
|
| 62 |
+
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|
README.md
CHANGED
|
@@ -3,8 +3,7 @@ title: ClassLens
|
|
| 3 |
emoji: 📊
|
| 4 |
colorFrom: green
|
| 5 |
colorTo: pink
|
| 6 |
-
sdk:
|
| 7 |
-
app_file: backend/static/report-template.html
|
| 8 |
license: mit
|
| 9 |
---
|
| 10 |
|
|
|
|
| 3 |
emoji: 📊
|
| 4 |
colorFrom: green
|
| 5 |
colorTo: pink
|
| 6 |
+
sdk: docker
|
|
|
|
| 7 |
license: mit
|
| 8 |
---
|
| 9 |
|