Tesseract OCR + 70 Debian packages + pip dependencies are now in a separate base image (klausur-base:latest) that is built once and reused. A --no-cache build now only rebuilds the code layer (~seconds) instead of re-downloading 33 MB of system packages (~9 minutes). Rebuild base when requirements.txt or system deps change: docker build -f klausur-service/Dockerfile.base -t klausur-base:latest klausur-service/ Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
37 lines
1.0 KiB
Docker
37 lines
1.0 KiB
Docker
# Build stage for React frontend
|
|
FROM node:20-alpine AS frontend-builder
|
|
|
|
WORKDIR /frontend
|
|
COPY frontend/package*.json ./
|
|
RUN npm install
|
|
|
|
COPY frontend/ ./
|
|
RUN npm run build
|
|
|
|
# Production stage — uses pre-built base with Tesseract + Python deps.
|
|
# Base image contains: python:3.11-slim + tesseract-ocr + all pip packages.
|
|
# Rebuild base only when requirements.txt or system deps change:
|
|
# docker build -f klausur-service/Dockerfile.base -t klausur-base:latest klausur-service/
|
|
FROM klausur-base:latest
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy backend code (this is the only layer that changes on code edits)
|
|
COPY backend/ ./
|
|
|
|
# Copy built frontend to the expected path
|
|
COPY --from=frontend-builder /frontend/dist ./frontend/dist
|
|
|
|
# Create uploads directory
|
|
RUN mkdir -p /app/uploads
|
|
|
|
# Expose port
|
|
EXPOSE 8086
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
|
CMD curl -f http://localhost:8086/health || exit 1
|
|
|
|
# Run the application
|
|
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8086"]
|