Dockerfile 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # Multi-stage build: Frontend + Backend + Worker in one image
  2. # ============================================================
  3. # Stage 1: Build frontend
  4. FROM node:20-alpine AS frontend-builder
  5. WORKDIR /app/frontend
  6. COPY frontend/package.json frontend/yarn.lock ./
  7. RUN yarn install --frozen-lockfile
  8. COPY frontend/ ./
  9. RUN yarn build
  10. # Stage 2: Python runtime
  11. FROM python:3.11-slim AS runtime
  12. # Install system dependencies
  13. RUN apt-get update && apt-get install -y --no-install-recommends \
  14. gcc \
  15. libpq-dev \
  16. && rm -rf /var/lib/apt/lists/*
  17. WORKDIR /app
  18. # Install Python dependencies
  19. COPY backend/requirements.txt ./
  20. RUN pip install --no-cache-dir -r requirements.txt gunicorn
  21. # Copy backend code
  22. COPY backend/ ./
  23. # Copy frontend build to static folder
  24. COPY --from=frontend-builder /app/frontend/dist ./static
  25. # Copy report template
  26. COPY sample-reports/ ./sample-reports/
  27. # Create necessary directories
  28. RUN mkdir -p uploads reports uploads/scan_data instance
  29. # Environment variables
  30. ENV FLASK_ENV=production
  31. ENV PYTHONUNBUFFERED=1
  32. # Expose port
  33. EXPOSE 5000
  34. # Default command: run web server
  35. CMD ["gunicorn", "--bind", "0.0.0.0:5000", "--workers", "4", "run:app"]