Spaces:
Sleeping
Sleeping
| # Stage 1: Build the frontend | |
| FROM node:20-slim AS frontend-builder | |
| WORKDIR /app/frontend | |
| COPY frontend/package*.json ./ | |
| RUN npm install | |
| COPY frontend/ ./ | |
| RUN npm run build | |
| # Stage 2: Final image with Python backend | |
| FROM python:3.10-slim | |
| WORKDIR /app | |
| # Install system dependencies for OpenCV/Pillow | |
| RUN apt-get update && apt-get install -y \ | |
| libglib2.0-0 \ | |
| libsm6 \ | |
| libxext6 \ | |
| libxrender-dev \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy requirements and install | |
| COPY backend/requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy built frontend from Stage 1 | |
| COPY --from=frontend-builder /app/frontend/dist ./frontend/dist | |
| # Copy backend and supporting code | |
| COPY backend/ ./backend/ | |
| COPY model/ ./model/ | |
| COPY utils/ ./utils/ | |
| # Hugging Face Spaces uses port 7860 by default | |
| ENV PORT=7860 | |
| EXPOSE 7860 | |
| # We use the PORT environment variable in main.py | |
| CMD ["python", "-m", "uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "7860"] | |