File size: 1,462 Bytes
788eab4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Multi-stage Dockerfile for Hugging Face Spaces & Production Cloud Containers
# 1. Build Frontend Production Bundle
FROM node:20-alpine AS frontend-builder
WORKDIR /app/frontend
COPY frontend/package*.json ./
RUN npm install
COPY frontend/ ./
RUN npm run build

# 2. Production Python Backend & Static SPA Host
FROM python:3.11-slim

# Install essential system libraries for CP-SAT solver and document parsers
RUN apt-get update && apt-get install -y --no-install-recommends \

    gcc \
    g++ \
    libgomp1 \
    && rm -rf /var/lib/apt/lists/*

# Set up user with UID 1000 for Hugging Face Spaces security
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH \
    PORT=7860 \
    HOST=0.0.0.0

WORKDIR /home/user/app

# Install python dependencies from pyproject.toml
COPY --chown=user pyproject.toml ./
RUN pip install --no-cache-dir --user -e .

# Copy application source and seed fixtures
COPY --chown=user backend/ ./backend/
COPY --chown=user fixtures/ ./fixtures/
COPY --chown=user scripts/ ./scripts/

# Copy compiled frontend SPA from builder stage
COPY --chown=user --from=frontend-builder /app/frontend/dist ./frontend/dist

# Ingest baseline 1,800 student records into SQLite
RUN python scripts/load_all_1800_students.py

# Expose server port (Hugging Face Spaces uses 7860)
EXPOSE 7860

# Start unified server
CMD ["python", "scripts/lan_launcher.py"]