File size: 1,847 Bytes
8052574
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0b8155d
 
 
8052574
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fd2bf85
 
 
 
 
 
8052574
 
 
 
 
 
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
# ═══════════════════════════════════════════════════════════════════════
# 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"]