# ═══════════════════════════════════════════════════════════════════════ # Dockerfile — Tipitaka Webapp (React + FastAPI) # Target: Hugging Face Space (port 7860) # ═══════════════════════════════════════════════════════════════════════ # ── Stage 1: Build React frontend ── FROM node:20-alpine AS frontend-builder WORKDIR /build COPY webapp/tipitaka-web/package*.json ./ RUN npm ci COPY webapp/tipitaka-web/ ./ RUN npm run build # ── Stage 2: Python backend + serve ── FROM python:3.11-slim ENV HOME=/tmp ENV HF_HOME=/tmp/hf_home WORKDIR /app # Install system dependencies (for sentence-transformers / torch) RUN apt-get update && apt-get install -y \ build-essential \ curl \ git \ && rm -rf /var/lib/apt/lists/* # ── Copy frontend build ── COPY --from=frontend-builder /build/dist ./web/dist/ # ── Copy & install Python deps ── COPY webapp/tipitaka-api/requirements.txt ./api/requirements.txt RUN pip install --no-cache-dir -r api/requirements.txt # ── Copy API code (includes download_assets.py + startup.sh) ── COPY webapp/tipitaka-api/ ./api/ # ── Make startup.sh executable ── RUN chmod +x /app/api/startup.sh # ── Create data directory (DB + vector files downloaded at runtime) and set permissions ── RUN mkdir -p /app/data/qdrant_storage /app/data/snapshots && \ chown -R 1000:1000 /app # ── Run as non-root user (UID 1000) ── USER 1000 # ── Port (HF Space expects 7860) ── EXPOSE 7860 # ── Entrypoint ── CMD ["bash", "api/startup.sh"]