File size: 1,269 Bytes
bf5da6b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# -----------------------------
# 1️⃣ Build Frontend
# -----------------------------
FROM node:18-bullseye AS frontend-builder
WORKDIR /app/frontend
COPY frontend/package*.json ./
RUN npm install
COPY frontend/ .
RUN npm run build

# -----------------------------
# 2️⃣ Build Backend
# -----------------------------
FROM python:3.10-slim-bullseye

WORKDIR /app

# Install essential system libraries for OpenCV, YOLO, and Ultralytics
RUN apt-get update && apt-get install -y \
    libgl1 \
    libglib2.0-0 \
    libgomp1 \
 && apt-get clean && rm -rf /var/lib/apt/lists/*

# Copy backend source code
COPY backend/ .

# Copy built frontend into the right folder for FastAPI
# ✅ this must match your app.mount() path in app.py
COPY --from=frontend-builder /app/frontend/dist ./frontend/dist

# Install Python dependencies
RUN pip install --upgrade pip
RUN pip install -r requirements.txt || pip install -r backend/requirements.txt || true

# Install runtime dependencies explicitly
RUN pip install --no-cache-dir fastapi uvicorn python-multipart ultralytics opencv-python-headless pillow numpy scikit-learn tensorflow keras

# Hugging Face Spaces expect port 7860
EXPOSE 7860

# Run FastAPI app
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]