diff --git a/Dockerfile b/Dockerfile index 3a38a904..d4ae7981 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,91 +1,54 @@ # OCRmyPDF # -# VERSION 3.2 -FROM debian:stretch +# VERSION 4.4.2 +FROM ubuntu:16.10 MAINTAINER James R. Barlow -# Add unprivileged user +RUN apt-get update && apt-get install -y --no-install-recommends \ + software-properties-common python-software-properties \ + python3-wheel \ + python3-reportlab \ + python3-venv \ + ghostscript \ + qpdf \ + poppler-utils \ + unpaper \ + libffi-dev \ + tesseract-ocr \ + tesseract-ocr-eng \ + tesseract-ocr-fra \ + tesseract-ocr-spa \ + tesseract-ocr-deu + +RUN python3 -m venv --system-site-packages /appenv + +# This installs the latest binary wheel instead of the code in the current +# folder. Installing from source will fail, apparently because cffi needs +# build-essentials (gcc) to do a source installation +# (i.e. "pip install ."). It's unclear to me why this is the case. +RUN . /appenv/bin/activate; \ + pip install --upgrade pip \ + && pip install ocrmypdf + +# Now copy the application in, mainly to get the test suite. +# Do this now to make the best use of Docker cache. +COPY . /application +RUN . /appenv/bin/activate; \ + pip install -r /application/test_requirements.txt + +# Remove the junk, including the source version of application since it was +# already installed +RUN rm -rf /tmp/* /var/tmp/* /root/* /application/ocrmypdf \ + && apt-get autoremove -y \ + && apt-get autoclean -y + RUN useradd docker \ && mkdir /home/docker \ && chown docker:docker /home/docker -# Update system and install our dependencies -# If this command takes too Docker hub's automated build will timeout, -# so try it in portions -RUN apt-get update && apt-get install -y --no-install-recommends \ - locales \ - python3 \ - python3-pip \ - python3-venv \ - python3-reportlab \ - python3-pil \ - python3-wheel - -RUN apt-get install -y --no-install-recommends \ - unpaper \ - qpdf \ - poppler-utils \ - tesseract-ocr \ - tesseract-ocr-deu tesseract-ocr-spa tesseract-ocr-eng tesseract-ocr-fra - -RUN apt-get install -qy --no-install-recommends \ - libffi-dev \ - libpython3-dev \ - gcc - -# Install Ghostscript from Debian sid to work around JPEG 2000 issue in -# Debian stretch libgs9 or gs 9.16~dfsg-2.1 - -COPY ./share/etc-apt-sources.list /etc/apt/sources.list - -RUN apt-get update && apt-get install -y ghostscript/sid - - -# Enforce UTF-8 -# Borrowed from https://index.docker.io/u/crosbymichael/python/ -RUN dpkg-reconfigure locales && \ - locale-gen C.UTF-8 && \ - /usr/sbin/update-locale LANG=C.UTF-8 -ENV LC_ALL C.UTF-8 - - -# Set up a Python virtualenv and take all of the system packages, so we can -# rely on the platform packages rather than importing GCC and compiling them -RUN pyvenv /appenv \ - && pyvenv --system-site-packages /appenv - -COPY . /application/ - -# Replace stock Tesseract 3.04.00 font with improved sharp2.ttf that resolves -# issues in many PDF viewers. -# Discussion is in https://github.com/tesseract-ocr/tesseract/issues/182 -COPY ./share/sharp2.ttf /usr/share/tesseract-ocr/tessdata/pdf.ttf -RUN chmod 644 /usr/share/tesseract-ocr/tessdata/pdf.ttf - -# Set this here to force a docker version, allowing non-tagged versions to -# be built -# ENV SETUPTOOLS_SCM_PRETEND_VERSION=v3.3.0 - -# Install application and dependencies -# In this arrangement Pillow and reportlab will be provided by the system -# Even though ocrmypdf is locally present, pull from PyPI because -# Dockerhub and setuptools_scm clash -RUN . /appenv/bin/activate; \ - pip install --upgrade pip \ - && pip install ocrmypdf \ - && pip install --no-cache-dir -r /application/test_requirements.txt - -# Remove the junk -RUN apt-get remove -qy gcc -RUN apt-get autoremove -y && apt-get clean -y -RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /root/* - USER docker WORKDIR /home/docker -ENV OCRMYPDF_TEST_OUTPUT=/tmp/test-output -ENV OCRMYPDF_SHARP_TTF=1 - # Must use array form of ENTRYPOINT # Non-array form does not append other arguments, because that is "intuitive" -ENTRYPOINT ["/application/docker-wrapper.sh"] \ No newline at end of file +ENTRYPOINT ["/application/docker-wrapper.sh"] diff --git a/Dockerfile.polyglot b/Dockerfile.polyglot index 94316b3f..f5accb4f 100644 --- a/Dockerfile.polyglot +++ b/Dockerfile.polyglot @@ -1,14 +1,17 @@ # OCRmyPDF polyglot # -# VERSION 3.2 +# VERSION 4.4.2 FROM jbarlow83/ocrmypdf:latest MAINTAINER James R. Barlow -# Update system and install our dependencies USER root + +# Update system and install our dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ tesseract-ocr-all +RUN apt-get autoremove -y && apt-get clean -y + USER docker # Must use array form of ENTRYPOINT diff --git a/Dockerfile.tess4 b/Dockerfile.tess4 index 594ae0a6..d394ec8d 100644 --- a/Dockerfile.tess4 +++ b/Dockerfile.tess4 @@ -1,46 +1,20 @@ # OCRmyPDF # -# VERSION 4.4.1 -FROM ubuntu:16.10 +# VERSION 4.4.2 +FROM jbarlow83/ocrmypdf:latest MAINTAINER James R. Barlow -RUN apt-get update && apt-get install -y --no-install-recommends \ - software-properties-common python-software-properties \ - python3-wheel \ - python3-reportlab \ - python3-venv \ - ghostscript \ - qpdf \ - poppler-utils \ - unpaper \ - libffi-dev +USER root RUN add-apt-repository ppa:alex-p/tesseract-ocr RUN apt-get update && apt-get install -y --no-install-recommends \ tesseract-ocr-all -RUN python3 -m venv --system-site-packages /appenv - -COPY . /application - -# This installs the latest binary wheel instead of the code in the current -# folder. cffi needs gcc otherwise. -RUN . /appenv/bin/activate; \ - pip install --upgrade pip \ - && pip install ocrmypdf \ - && pip install -r /application/test_requirements.txt - -# Remove the junk, including the source version of application RUN apt-get autoremove -y && apt-get clean -y -RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /root/* /application/ocrmypdf - -RUN useradd docker \ - && mkdir /home/docker \ - && chown docker:docker /home/docker USER docker -WORKDIR /home/docker + # Must use array form of ENTRYPOINT # Non-array form does not append other arguments, because that is "intuitive" diff --git a/MANIFEST.in b/MANIFEST.in index 450f48c8..8f3cdf7f 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -36,7 +36,6 @@ recursive-exclude docs/_build * # support files recursive-include ocrmypdf/data * -recursive-include share * include *.py exclude tasks.py diff --git a/share/etc-apt-sources.list b/share/etc-apt-sources.list deleted file mode 100644 index f4072c67..00000000 --- a/share/etc-apt-sources.list +++ /dev/null @@ -1,4 +0,0 @@ -deb http://httpredir.debian.org/debian stretch main -deb http://httpredir.debian.org/debian stretch-updates main -deb http://security.debian.org stretch/updates main -deb http://ftp.de.debian.org/debian sid main contrib non-free \ No newline at end of file diff --git a/share/sharp2.ttf b/share/sharp2.ttf deleted file mode 100644 index 578974a9..00000000 Binary files a/share/sharp2.ttf and /dev/null differ