From 39214e1b2b317dbb1daff15e2d8526ff0c215070 Mon Sep 17 00:00:00 2001 From: Manuel Date: Thu, 18 Sep 2025 14:52:14 +0200 Subject: [PATCH] docker --- Dockerfile | 91 +++++++++++++++++++++++++++--------------------- requirements.txt | 1 + 2 files changed, 53 insertions(+), 39 deletions(-) diff --git a/Dockerfile b/Dockerfile index 646b6f0..72a8114 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,61 +1,74 @@ -# Dockerfile +# STAGE 1: BUILDER +# This stage installs build tools and Python dependencies +FROM python:3.13.7-slim AS builder + +ENV PYTHONUNBUFFERED=1 \ + DEBIAN_FRONTEND=noninteractive + +# Install only the build-time dependencies needed for pip packages +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential \ + pkg-config \ + git \ + curl \ + libxml2-dev \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /app + +# Copy and install Python requirements to leverage Docker layer caching +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt + + +# STAGE 2: FINAL +# This is the lean, final image for running the application FROM python:3.13.7-slim ENV PYTHONUNBUFFERED=1 \ DEBIAN_FRONTEND=noninteractive +# Install only the essential runtime dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ - tesseract-ocr \ - tesseract-ocr-eng \ - tesseract-ocr-deu \ - ghostscript \ - poppler-utils \ + # OCR dependencies + tesseract-ocr tesseract-ocr-eng tesseract-ocr-deu ghostscript poppler-utils \ libreoffice \ - imagemagick \ - graphicsmagick \ - libvips-tools \ - ffmpeg \ - libheif-examples \ - inkscape \ - calibre \ - pngquant \ - pandoc \ - resvg \ - sox \ - libvips-tools \ - build-essential \ - pkg-config \ - git \ - potrace \ - curl \ - texlive \ - jpegoptim \ + pandoc texlive-xetex \ texlive-latex-recommended \ texlive-fonts-recommended \ - libxml2 \ - texlive-xetex \ - texlive-science \ + calibre \ + ffmpeg \ + libvips-tools \ libxml2-dev \ + graphicsmagick \ + inkscape \ + resvg \ + potrace \ + pngquant \ + sox \ + jpegoptim \ + libsox-fmt-mp3 \ + lame \ + # Runtime libraries for Python packages + libxml2 \ + # Process manager supervisor \ && rm -rf /var/lib/apt/lists/* - -# Set working directory inside the container WORKDIR /app -# Copy requirements and install dependencies -COPY requirements.txt . -RUN pip install --no-cache-dir -r requirements.txt -COPY supervisor.conf /etc/supervisor/conf.d/supervisor.conf +# Copy installed Python packages from the builder stage +COPY --from=builder /usr/local/lib/python3.13/site-packages /usr/local/lib/python3.13/site-packages +COPY --from=builder /usr/local/bin /usr/local/bin -# Copy the rest of the app +# Copy supervisor config and application code +COPY supervisor.conf /etc/supervisor/conf.d/supervisor.conf COPY . . - -# Expose the app port +# Expose port and set executable permissions EXPOSE 8000 RUN chmod +x run.sh -# Command to run when container starts -#CMD ["./run.sh"] + +# Start the application CMD ["/usr/bin/supervisord", "-n"] diff --git a/requirements.txt b/requirements.txt index 3391c93..8e07724 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,6 +15,7 @@ pytesseract pypdf # Configuration & Utilities +werkzeug PyYAML pydantic pydantic-settings