Dockerfile 920 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. # Stage 1: Build Frontend
  2. FROM node:18 AS frontend-builder
  3. WORKDIR /app/frontend
  4. COPY frontend/package*.json ./
  5. RUN npm install
  6. COPY frontend/ ./
  7. # Build the frontend. The output should be in frontend/dist
  8. RUN npm run build
  9. # Stage 2: Backend Runtime
  10. FROM python:3.10-slim
  11. WORKDIR /app
  12. # Install system dependencies required for OpenCV
  13. RUN apt-get update && apt-get install -y \
  14. libgl1 \
  15. libglib2.0-0 \
  16. && rm -rf /var/lib/apt/lists/*
  17. # Install Python dependencies
  18. COPY backend/requirements.txt .
  19. RUN pip install --no-cache-dir -r requirements.txt
  20. # Copy backend code
  21. COPY backend/ ./backend/
  22. COPY run.py .
  23. # Copy built frontend assets to backend/dist (as expected by main.py)
  24. COPY --from=frontend-builder /app/frontend/dist ./backend/dist
  25. # Create directories for volumes
  26. RUN mkdir -p reports backend/app/static/snapshots
  27. # Expose the port
  28. EXPOSE 8000
  29. # Run the application
  30. CMD ["python", "run.py"]