From 8138664287d9bd018745c5b2fa31d97a801d1809 Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Sun, 27 Oct 2024 16:14:08 -0700 Subject: [PATCH] Remove Ubuntu 22.04 container --- .docker/Dockerfile | 65 +++++++++---------------------------- .docker/Dockerfile.ubuntu24 | 57 -------------------------------- 2 files changed, 16 insertions(+), 106 deletions(-) delete mode 100644 .docker/Dockerfile.ubuntu24 diff --git a/.docker/Dockerfile b/.docker/Dockerfile index b58c381d1..6df10e3ce 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -1,7 +1,7 @@ -# SPDX-FileCopyrightText: 2022 James R. Barlow +# SPDX-FileCopyrightText: 2024 James R. Barlow # SPDX-License-Identifier: MPL-2.0 -FROM ubuntu:22.04 as base +FROM ubuntu:24.04 AS base ENV LANG=C.UTF-8 ENV TZ=UTC @@ -9,62 +9,34 @@ RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selectio RUN apt-get update && apt-get install -y --no-install-recommends \ python3 \ - libqpdf-dev \ - zlib1g \ - liblept5 + python-is-python3 -FROM base as builder +FROM base AS builder -# Note we need leptonica here to build jbig2 RUN apt-get update && apt-get install -y --no-install-recommends \ - build-essential autoconf automake libtool \ - libleptonica-dev \ - zlib1g-dev \ - python3-dev \ - python3-distutils \ - libffi-dev \ - ca-certificates \ - curl \ + python3-pip \ + python3-venv \ git \ - libcairo2-dev \ - pkg-config - -# Get the latest pip (Ubuntu version doesn't support manylinux2010) -RUN \ - curl https://bootstrap.pypa.io/get-pip.py | python3 - -# Compile and install jbig2 -# Needs libleptonica-dev, zlib1g-dev -RUN \ - mkdir jbig2 \ - && curl -L https://github.com/agl/jbig2enc/archive/ea6a40a.tar.gz | \ - tar xz -C jbig2 --strip-components=1 \ - && cd jbig2 \ - && ./autogen.sh && ./configure && make && make install \ - && cd .. \ - && rm -rf jbig2 + curl COPY . /app WORKDIR /app -RUN pip3 install --no-cache-dir .[test,webservice,watcher] +RUN curl -LsSf https://astral.sh/uv/0.4.27/install.sh | sh -FROM base +ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy -# For Tesseract 5 -RUN apt-get update && apt-get install -y --no-install-recommends \ - software-properties-common gpg-agent -RUN add-apt-repository -y ppa:alex-p/tesseract-ocr-devel +# Instead of restarting the shell, use uv directly from its installed location. +RUN /root/.cargo/bin/uv sync --extra test --extra webservice --extra watcher + +FROM base RUN apt-get update && apt-get install -y --no-install-recommends \ ghostscript \ fonts-droid-fallback \ jbig2dec \ - img2pdf \ - libsm6 libxext6 libxrender-dev \ pngquant \ - python-is-python3 \ tesseract-ocr \ tesseract-ocr-chi-sim \ tesseract-ocr-deu \ @@ -77,14 +49,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ WORKDIR /app -COPY --from=builder /usr/local/lib/ /usr/local/lib/ -COPY --from=builder /usr/local/bin/ /usr/local/bin/ +COPY --from=builder --chown=app:app /app /app -COPY --from=builder /app/misc/webservice.py /app/ -COPY --from=builder /app/misc/watcher.py /app/ +ENV PATH="/app/.venv/bin:${PATH}" -# Copy minimal project files to get the test suite. -COPY --from=builder /app/pyproject.toml /app/README.md /app/ -COPY --from=builder /app/tests /app/tests +ENTRYPOINT ["/app/.venv/bin/ocrmypdf"] -ENTRYPOINT ["/usr/local/bin/ocrmypdf"] diff --git a/.docker/Dockerfile.ubuntu24 b/.docker/Dockerfile.ubuntu24 deleted file mode 100644 index 6df10e3ce..000000000 --- a/.docker/Dockerfile.ubuntu24 +++ /dev/null @@ -1,57 +0,0 @@ -# SPDX-FileCopyrightText: 2024 James R. Barlow -# SPDX-License-Identifier: MPL-2.0 - -FROM ubuntu:24.04 AS base - -ENV LANG=C.UTF-8 -ENV TZ=UTC -RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections - -RUN apt-get update && apt-get install -y --no-install-recommends \ - python3 \ - python-is-python3 - -FROM base AS builder - -RUN apt-get update && apt-get install -y --no-install-recommends \ - python3-pip \ - python3-venv \ - git \ - curl - -COPY . /app - -WORKDIR /app - -RUN curl -LsSf https://astral.sh/uv/0.4.27/install.sh | sh - -ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy - -# Instead of restarting the shell, use uv directly from its installed location. -RUN /root/.cargo/bin/uv sync --extra test --extra webservice --extra watcher - -FROM base - -RUN apt-get update && apt-get install -y --no-install-recommends \ - ghostscript \ - fonts-droid-fallback \ - jbig2dec \ - pngquant \ - tesseract-ocr \ - tesseract-ocr-chi-sim \ - tesseract-ocr-deu \ - tesseract-ocr-eng \ - tesseract-ocr-fra \ - tesseract-ocr-por \ - tesseract-ocr-spa \ - unpaper \ - && rm -rf /var/lib/apt/lists/* - -WORKDIR /app - -COPY --from=builder --chown=app:app /app /app - -ENV PATH="/app/.venv/bin:${PATH}" - -ENTRYPOINT ["/app/.venv/bin/ocrmypdf"] -