File size: 968 Bytes
d790e98
7dc08c6
d790e98
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Stage 1: Build React Frontend
FROM node:20-alpine as builder
WORKDIR /app
COPY frontend/ ./frontend/
WORKDIR /app/frontend
RUN npm install
# Create the output directory structure expected by vite.config.ts
RUN mkdir -p ../static/react
RUN npm run build

# Stage 2: Python Backend
FROM python:3.10-slim

# Install system dependencies for OpenCV and others
RUN apt-get update && apt-get install -y \
    libgl1 \
    libglib2.0-0 \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Copy requirements and install dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy backend code
COPY . .

# Copy built frontend from builder stage
# Note: Vite build output was configured to ../static/react, so it's at /app/static/react in builder
COPY --from=builder /app/static/react ./static/react

# Expose the port
# Expose the port (Hugging Face Spaces uses 7860)
EXPOSE 7860

# Command to run the application
CMD ["python", "app.py"]