File size: 923 Bytes
c07244c
 
a6ee555
 
 
 
 
 
c07244c
a6ee555
 
 
 
 
 
 
 
9785b99
a6ee555
 
 
 
de22824
94de5c6
 
de22824
606634c
a6ee555
de22824
a6ee555
de22824
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
# Stage 1: Build frontend
FROM node:20-alpine AS frontend-builder
WORKDIR /frontend
COPY frontend/package*.json ./
RUN npm ci
COPY frontend/ ./
RUN npm run build

# Stage 2: Build backend
FROM python:3.11-slim
WORKDIR /app

RUN apt-get update && apt-get install -y --no-install-recommends \
    libgomp1 \
    && rm -rf /var/lib/apt/lists/*

COPY backend/requirements.txt ./backend/
RUN pip install --no-cache-dir --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cpu -r ./backend/requirements.txt

COPY backend/ ./backend/
COPY --from=frontend-builder /frontend/dist ./frontend/dist

# Pre-download model so container starts fast (avoids HF Spaces startup timeout)
COPY scripts/setup_model.py /tmp/setup_model.py
RUN python /tmp/setup_model.py && rm /tmp/setup_model.py

ENV PORT=7860 HOST=0.0.0.0 PYTHONPATH=/app

EXPOSE 7860

CMD python -m uvicorn backend.app.main:app --host 0.0.0.0 --port ${PORT:-7860}