# --- Stage 1: Build Frontend --- FROM node:18 AS build-frontend WORKDIR /app/frontend COPY frontend/package*.json ./ RUN npm install COPY frontend/ ./ RUN npm run build # --- Stage 2: Final Runtime --- FROM python:3.10-slim WORKDIR /app # Install system dependencies for OpenCV and YOLO RUN apt-get update && apt-get install -y \ libgl1 \ libglib2.0-0 \ libsm6 \ libxext6 \ libxrender-dev \ ffmpeg \ && rm -rf /var/lib/apt/lists/* # Install Python requirements COPY api/requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy backend code COPY api/ . # Copy built frontend from Stage 1 into the backend's static directory COPY --from=build-frontend /app/frontend/dist ./static # Expose Hugging Face Space default port EXPOSE 7860 # Command to run the app CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]