File size: 1,320 Bytes
82e5025
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
365d8a2
 
 
82e5025
 
 
 
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
# Multi-stage build for Hugging Face Spaces (Docker) with single URL serving

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

# --- Backend stage ---
FROM python:3.11-slim AS runtime

# System deps for OpenCV and general libs
RUN apt-get update && apt-get install -y --no-install-recommends \
    libgl1 \
    libglib2.0-0 \
    libsm6 \
    libxext6 \
    libxrender1 \
    build-essential \
    python3-dev \
    git \
    curl \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Install backend deps
COPY backend/requirements.txt /app/backend/requirements.txt
RUN pip install --upgrade pip && \
    pip install --no-cache-dir -r /app/backend/requirements.txt

# Copy application code
COPY backend /app/backend
COPY content /app/content

# Copy built frontend
COPY --from=frontend-build /app/dist /app/frontend_dist

# Environment
ENV PORT=7860 \
    DATA_DIR=/data \
    FRONTEND_DIST=/app/frontend_dist

# Ensure data dir exists with permissive permissions (in case volume isn't mounted yet)
RUN mkdir -p /data && chmod -R 777 /data

EXPOSE 7860

# Run FastAPI (serve API + static frontend)
CMD ["python", "-m", "uvicorn", "app.main:app", "--app-dir", "backend", "--host", "0.0.0.0", "--port", "7860"]