diff --git a/.docker/Dockerfile b/.docker/Dockerfile index 8661d9c7..ceb69bb0 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -1,6 +1,6 @@ # OCRmyPDF # -FROM ubuntu:19.04 as base +FROM ubuntu:19.10 as base FROM base as builder @@ -10,16 +10,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential autoconf automake libtool \ libleptonica-dev \ zlib1g-dev \ - ocrmypdf \ - pngquant \ + python3-setuptools \ python3-pip \ - python3-venv \ - tesseract-ocr \ - unpaper \ wget \ git - # Compile and install jbig2 # Needs libleptonica-dev, zlib1g-dev RUN \ @@ -31,15 +26,15 @@ RUN \ && cd .. \ && rm -rf jbig2 -RUN python3 -m venv /appenv - COPY . /app WORKDIR /app -RUN . /appenv/bin/activate; \ - pip install --upgrade pip \ - && pip install . +RUN pip3 install \ + -r requirements/main.txt \ + -r requirements/webservice.txt \ + -r requirements/test.txt \ + . FROM base @@ -53,7 +48,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ zlib1g \ pngquant \ python3 \ - python3-venv \ qpdf \ tesseract-ocr \ tesseract-ocr-chi-sim \ @@ -62,10 +56,13 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ tesseract-ocr-fra \ tesseract-ocr-por \ tesseract-ocr-spa \ - unpaper \ - wget + unpaper + +WORKDIR /app + +COPY --from=builder /usr/local/lib/python3.7/dist-packages/ /usr/local/lib/python3.7/dist-packages/ +COPY --from=builder /usr/local/bin/ocrmypdf /usr/local/bin/ocrmypdf -# Copy COPY --from=builder /app/misc/webservice.py /app/ # Copy minimal project files to get the test suite. @@ -74,7 +71,4 @@ COPY --from=builder /app/requirements /app/requirements COPY --from=builder /app/tests /app/tests COPY --from=builder /app/src /app/src -COPY --from=builder /appenv /appenv -COPY --from=builder /usr/local /usr/local - -ENTRYPOINT ["/appenv/bin/ocrmypdf"] +ENTRYPOINT ["/usr/local/bin/ocrmypdf"] diff --git a/docs/docker.rst b/docs/docker.rst index 4cd34d83..ed118dfc 100644 --- a/docs/docker.rst +++ b/docs/docker.rst @@ -117,7 +117,7 @@ The OCRmyPDF test suite is installed with image. To run it: .. code-block:: bash - docker run --entrypoint python3 jbarlow83/ocrmypdf setup.py test + docker run --entrypoint python3 jbarlow83/ocrmypdf -m pytest Accessing the shell =================== diff --git a/requirements/main.txt b/requirements/main.txt index 5db7550a..eec5dc7a 100644 --- a/requirements/main.txt +++ b/requirements/main.txt @@ -1,13 +1,10 @@ # requirements.txt can be used to replicate the developer's build environment # setup.py lists a separate set of requirements that are looser to simplify # installation -chardet == 3.0.4 -cffi == 1.12.2 +cffi == 1.13.2 img2pdf == 0.3.3 pdfminer.six == 20181108 pikepdf == 1.6.5 Pillow >= 6.2.0 -pycparser == 2.19 -python-xmp-toolkit == 2.0.1 -reportlab == 3.5.13 -tqdm == 4.32.1 +reportlab == 3.5.32 +tqdm == 4.37.0 diff --git a/requirements/test.txt b/requirements/test.txt index 975325bd..58fd0fdd 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -2,7 +2,7 @@ pytest >= 5.0.0 pytest-helpers-namespace >= 2019.1.8 pytest-xdist >= 1.29.0 # For DumpError fix pytest-cov >= 2.6.1 -python-xmp-toolkit # requires apt-get install libexempi3 +python-xmp-toolkit == 2.0.1 # requires apt-get install libexempi3 # or brew install exempi PyPDF2 >= 1.26.0 #PyMuPDF == 1.13.4 # optional diff --git a/requirements/webservice.txt b/requirements/webservice.txt new file mode 100644 index 00000000..f6e3c4e6 --- /dev/null +++ b/requirements/webservice.txt @@ -0,0 +1 @@ +Flask >= 1, < 2 diff --git a/tests/test_completion.py b/tests/test_completion.py index 8fdbb59a..8837fbe2 100644 --- a/tests/test_completion.py +++ b/tests/test_completion.py @@ -19,6 +19,11 @@ from subprocess import run, PIPE import pytest +pytestmark = pytest.mark.skipif( + pytest.helpers.running_in_docker(), # pylint: disable=no-member + reason="docker can't complete", +) + def test_fish(): try: