File size: 884 Bytes
5d54b3c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Multi-stage: build frontend, then run FastAPI + static frontend
# Hugging Face Spaces: set DATA_DIR=/tmp/hawbeez-data (only /tmp is writable), port 7860

# --- Frontend build ---
FROM node:20-alpine AS frontend
WORKDIR /app/frontend
COPY frontend/package.json frontend/package-lock.json* ./
RUN npm ci
COPY frontend/ ./
RUN npm run build

# --- Backend + serve static ---
FROM python:3.12-slim
WORKDIR /app

# Backend deps
COPY backend/requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt

# Backend code
COPY backend/ ./

# Frontend build → app/static so FastAPI can serve it
COPY --from=frontend /app/frontend/dist ./app/static

# Hugging Face: writable dir (only /tmp is persistent)
ENV DATA_DIR=/tmp/hawbeez-data
ENV PORT=7860

EXPOSE 7860

# Run from backend dir so `app` package resolves
WORKDIR /app
CMD uvicorn app.main:app --host 0.0.0.0 --port ${PORT}