Spaces:
Sleeping
Sleeping
| # Stage 1: Build React frontend | |
| FROM node:20-alpine AS build | |
| WORKDIR /app/frontend | |
| COPY frontend/package.json ./ | |
| RUN npm install | |
| COPY frontend/ ./ | |
| RUN npm run build | |
| # Stage 2: Create Python runtime image | |
| FROM python:3.11-slim | |
| # Create a non-root user with UID 1000 as required by Hugging Face Spaces | |
| RUN useradd -m -u 1000 user | |
| WORKDIR /home/user/app | |
| # Install system dependencies | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| build-essential \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Install python requirements | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy application files | |
| COPY server.py socratic_graph.py ingest.py ingested_files.json ./ | |
| COPY utils/ ./utils/ | |
| COPY chroma_db/ ./chroma_db/ | |
| COPY data/ ./data/ | |
| # Copy React build artifacts | |
| COPY --from=build /app/frontend/dist ./frontend/dist | |
| # Set correct ownership for writing files (eval_logs.jsonl, data uploads, chromadb write operations) | |
| RUN chown -R user:user /home/user/app | |
| USER user | |
| # Set environmental variables | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH | |
| # Expose the port HF Spaces expects | |
| EXPOSE 7860 | |
| CMD ["uvicorn", "server:app", "--host", "0.0.0.0", "--port", "7860"] | |