From c56f692ff5dc5a542729d4ddc385b782cad0503a Mon Sep 17 00:00:00 2001 From: Malte Date: Tue, 27 Oct 2020 06:00:55 +0100 Subject: [PATCH 1/4] (DOCKER) allows to use jbarlow83's official docker image of OCRmyPDF, i.e. use a newer version - if `/var/run/docker.sock` is found in the docker-container, this feature is activated - if not, nothing changes - usage: mount bind `docker.sock` from host by using `-v` or `volumes:` --- docker/joex-entrypoint.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docker/joex-entrypoint.sh b/docker/joex-entrypoint.sh index 3ed3df29..a2d44b23 100755 --- a/docker/joex-entrypoint.sh +++ b/docker/joex-entrypoint.sh @@ -3,4 +3,15 @@ echo "Starting unoconv listener" unoconv -l & +# replace own ocrmypdf with official dockerfile, i.e. newer version +if [ -S "/var/run/docker.sock" ]; then + echo "Found 'docker.sock': Installing Docker and redirecting 'ocrmypdf' command to official dockerfile by jbarlow83" + apk --no-cache add docker + docker pull jbarlow83/ocrmypdf + function ocrmypdf () { + docker run jbarlow83/ocrmypdf $@ + } + echo "Using OCRmyPDF v$(ocrmypdf --version)" && echo +fi + /opt/docspell-joex/bin/docspell-joex "$@" From e9db579af69d62dafaf9ce4b902b08e030d980d3 Mon Sep 17 00:00:00 2001 From: Malte Date: Tue, 27 Oct 2020 06:30:50 +0100 Subject: [PATCH 2/4] added environment variable to set preferred OCRmyPDF version when using docker image - e.g. `- OCRMYPDF_VERSION=v11.2.1` - default ist `latest` --- docker/joex-entrypoint.sh | 4 ++-- docker/joex.dockerfile | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docker/joex-entrypoint.sh b/docker/joex-entrypoint.sh index a2d44b23..9bfde864 100755 --- a/docker/joex-entrypoint.sh +++ b/docker/joex-entrypoint.sh @@ -7,9 +7,9 @@ unoconv -l & if [ -S "/var/run/docker.sock" ]; then echo "Found 'docker.sock': Installing Docker and redirecting 'ocrmypdf' command to official dockerfile by jbarlow83" apk --no-cache add docker - docker pull jbarlow83/ocrmypdf + docker pull -q jbarlow83/ocrmypdf:$OCRMYPDF_VERSION function ocrmypdf () { - docker run jbarlow83/ocrmypdf $@ + docker run jbarlow83/ocrmypdf:$OCRMYPDF_VERSION $@ } echo "Using OCRmyPDF v$(ocrmypdf --version)" && echo fi diff --git a/docker/joex.dockerfile b/docker/joex.dockerfile index 2c14613f..424f9a17 100644 --- a/docker/joex.dockerfile +++ b/docker/joex.dockerfile @@ -9,6 +9,8 @@ FROM ${REPO}:base-binaries-${VERSION} as docspell-base-binaries FROM ${REPO}:joex-base-${VERSION} +ENV OCRMYPDF_VERSION=latest + COPY --from=docspell-base-binaries /opt/docspell-joex /opt/docspell-joex COPY joex-entrypoint.sh /opt/joex-entrypoint.sh From cde7519f24d8fecfc9515bb5c362c7f909f5cade Mon Sep 17 00:00:00 2001 From: Malte Date: Tue, 27 Oct 2020 06:57:27 +0100 Subject: [PATCH 3/4] set default version of OCRmyPDF's docker image to _v11.2.1_, which seems to be the latest stable before _11.3.0_ --- docker/joex.dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/joex.dockerfile b/docker/joex.dockerfile index 424f9a17..16c04226 100644 --- a/docker/joex.dockerfile +++ b/docker/joex.dockerfile @@ -9,7 +9,7 @@ FROM ${REPO}:base-binaries-${VERSION} as docspell-base-binaries FROM ${REPO}:joex-base-${VERSION} -ENV OCRMYPDF_VERSION=latest +ENV OCRMYPDF_VERSION=v11.2.1 COPY --from=docspell-base-binaries /opt/docspell-joex /opt/docspell-joex COPY joex-entrypoint.sh /opt/joex-entrypoint.sh From 3d074c5fc98fd90266cf9d350c774719a6f1f535 Mon Sep 17 00:00:00 2001 From: Malte Date: Tue, 27 Oct 2020 12:37:37 +0100 Subject: [PATCH 4/4] Bugfixes - Using a script in `/usr/local/bin ` now to overwrit the default *ocrmypdf* version and thus replaced the approach using a bash function - Also had to add volume mapping to docker call **ATTENTION** the path /tmp/docspell-convert:/tmp/docspell-convert must be mapped when starting Docspell's docker image! --- docker/joex-entrypoint.sh | 15 +++++++++------ docker/joex-ocrmypdf.sh | 6 ++++++ docker/joex.dockerfile | 1 + 3 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 docker/joex-ocrmypdf.sh diff --git a/docker/joex-entrypoint.sh b/docker/joex-entrypoint.sh index 9bfde864..670d923e 100755 --- a/docker/joex-entrypoint.sh +++ b/docker/joex-entrypoint.sh @@ -5,13 +5,16 @@ unoconv -l & # replace own ocrmypdf with official dockerfile, i.e. newer version if [ -S "/var/run/docker.sock" ]; then - echo "Found 'docker.sock': Installing Docker and redirecting 'ocrmypdf' command to official dockerfile by jbarlow83" - apk --no-cache add docker + if [ ! -f "/usr/local/bin/ocrmypdf.sh" ]; then + echo "Found 'docker.sock': Installing Docker and redirecting 'ocrmypdf' command to official dockerfile by jbarlow83" + apk --no-cache add docker + + mv /usr/local/bin/joex-ocrmypdf.sh /usr/local/bin/ocrmypdf + chmod ug+x /usr/local/bin/ocrmypdf + fi + docker pull -q jbarlow83/ocrmypdf:$OCRMYPDF_VERSION - function ocrmypdf () { - docker run jbarlow83/ocrmypdf:$OCRMYPDF_VERSION $@ - } - echo "Using OCRmyPDF v$(ocrmypdf --version)" && echo + echo "Using OCRmyPDF@Docker v$(ocrmypdf --version)" && echo fi /opt/docspell-joex/bin/docspell-joex "$@" diff --git a/docker/joex-ocrmypdf.sh b/docker/joex-ocrmypdf.sh new file mode 100644 index 00000000..cce97a98 --- /dev/null +++ b/docker/joex-ocrmypdf.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +if [ ! "$1" == "--version" ]; then + echo "Using docker image for ocrmypdf (Version: $OCRMYPDF_VERSION)" +fi +docker run -v '/tmp/docspell-convert:/tmp/docspell-convert' -e "TZ=$TZ" jbarlow83/ocrmypdf:$OCRMYPDF_VERSION $@ diff --git a/docker/joex.dockerfile b/docker/joex.dockerfile index 16c04226..5feff808 100644 --- a/docker/joex.dockerfile +++ b/docker/joex.dockerfile @@ -13,6 +13,7 @@ ENV OCRMYPDF_VERSION=v11.2.1 COPY --from=docspell-base-binaries /opt/docspell-joex /opt/docspell-joex COPY joex-entrypoint.sh /opt/joex-entrypoint.sh +COPY joex-ocrmypdf.sh /usr/local/bin/joex-ocrmypdf.sh ENTRYPOINT ["/opt/joex-entrypoint.sh"] CMD ["/opt/docspell.conf"]