Dockerfile 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # Build frontend
  2. FROM node:22-bookworm-slim AS frontend-builder
  3. WORKDIR /app/frontend
  4. COPY frontend/package*.json ./
  5. RUN npm ci
  6. COPY frontend/ ./
  7. RUN npm run build
  8. # Production image
  9. FROM python:3.13-slim
  10. WORKDIR /app
  11. # Install system dependencies (curl for health checks/testing)
  12. RUN apt-get update && apt-get install -y --no-install-recommends curl \
  13. && rm -rf /var/lib/apt/lists/*
  14. # Install Python dependencies
  15. COPY requirements.txt ./
  16. RUN pip install --no-cache-dir -r requirements.txt
  17. # Copy backend
  18. COPY backend/ ./backend/
  19. # Copy built frontend from builder stage
  20. COPY --from=frontend-builder /app/static ./static
  21. # Create data directory for persistent storage
  22. RUN mkdir -p /app/data /app/logs
  23. # Environment variables
  24. ENV PYTHONUNBUFFERED=1
  25. ENV DATA_DIR=/app/data
  26. EXPOSE 8000
  27. # Health check
  28. HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
  29. CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')" || exit 1
  30. # Run the application
  31. CMD ["uvicorn", "backend.app.main:app", "--host", "0.0.0.0", "--port", "8000"]