diff --git a/docker/docker-compose/.env b/docker/docker-compose/.env new file mode 100644 index 00000000..7f5e39ae --- /dev/null +++ b/docker/docker-compose/.env @@ -0,0 +1,2 @@ +TZ=Europe/Berlin +DOCSPELL_HEADER_VALUE=none diff --git a/docker/docker-compose/docker-compose.yml b/docker/docker-compose/docker-compose.yml new file mode 100644 index 00000000..25a6139b --- /dev/null +++ b/docker/docker-compose/docker-compose.yml @@ -0,0 +1,80 @@ +version: '3.8' +services: + + restserver: + image: docspell/restserver:latest + container_name: docspell-restserver + command: + - /opt/docspell.conf + restart: unless-stopped + ports: + - "7880:7880" + volumes: + - ./docspell.conf:/opt/docspell.conf + env_file: ./.env + depends_on: + - solr + + joex: + image: docspell/joex:latest + container_name: docspell-joex + command: + - /opt/docspell.conf + restart: unless-stopped + env_file: ./.env + ports: + - "7878:7878" + volumes: + - ./docspell.conf:/opt/docspell.conf + depends_on: + - solr + + consumedir: + image: docspell/tools:latest + container_name: docspell-consumedir + command: + - ds-consumedir + - "-vmdi" + - "--path" + - "/opt/docs" + - "--iheader" + - "Docspell-Integration:$DOCSPELL_HEADER_VALUE" + - "http://docspell-restserver:7880/api/v1/open/integration/item" + restart: unless-stopped + env_file: ./.env + volumes: + - ./docs:/opt/docs + depends_on: + - restserver + + db: + image: postgres:13.3 + container_name: postgres_db + restart: unless-stopped + volumes: + - docspell-postgres_data:/var/lib/postgresql/data/ + environment: + - POSTGRES_USER=dbuser + - POSTGRES_PASSWORD=dbpass + - POSTGRES_DB=dbname + + solr: + image: solr:8 + container_name: docspell-solr + restart: unless-stopped + volumes: + - docspell-solr_data:/var/solr + command: + - solr-precreate + - docspell + healthcheck: + test: ["CMD", "curl", "f", "http://localhost:8983/solr/docspell/admin/ping"] + interval: 1m + timeout: 10s + retries: 2 + start_period: 30s + + +volumes: + docspell-postgres_data: + docspell-solr_data: diff --git a/docker/docker-compose/docspell.conf b/docker/docker-compose/docspell.conf new file mode 100644 index 00000000..03feea5e --- /dev/null +++ b/docker/docker-compose/docspell.conf @@ -0,0 +1,83 @@ +# This is the configuration file for docspell. It contains two main +# namespaces: docspell.server and docspell.joex. Each provide the +# config for the respective component. +# +# They can be moved to different files, if necessary. For this example +# though, both components are configured in this single file. +# +# Below are only some settings that differ from the default. Please +# see https://docspell.org/docs/configure/#default-config for all +# options and their documentation. This page provides more +# information about the important config options. +# +# Note: this docker-compose setup is an example to get started. It +# sets up one rest-server, one joex, a postgres database and a solr – +# all on the same machine. + +# Define settings that are used in multiple places: +db_url="jdbc:postgresql://db:5432/dbname" +db_user="dbuser" +db_pass="dbpass" +solr_url="http://docspell-solr:8983/docspell" + + +# This configures the restserver +docspell.server { + base-url = "http://localhost:7880" + bind { + address = "0.0.0.0" + } + integration-endpoint { + enabled = true + http-header { + enabled = true + header-value = ${?DOCSPELL_HEADER_VALUE} + } + } + # Configuration of the full-text search engine. + full-text-search { + enabled = true + solr = { + url = ${solr_url} + } + } + backend { + jdbc { + url = ${db_url} + user = ${db_user} + password = ${db_pass} + } + } +} + + +# This configures joex +# +# Note to joex: It is currently setup for one instance. Should you +# want to scale joex instance up (maybe to help processing a batch of +# files), there are two options: +# +# - look at https://github.com/eikek/docspell/pull/552 to elastically +# start and stop joex instances via docker-compose +# - set pool-size to some higher number; this requires to restart joex +# +docspell.joex { + base-url = "http://docspell-joex:7878" + bind { + address = "0.0.0.0" + } + jdbc { + url = ${db_url} + user = ${db_user} + password = ${db_pass} + } + full-text-search { + enabled = true + solr = { + url = ${solr_url} + } + } + scheduler { + pool-size = 1 + } +} diff --git a/docker/dockerfiles/build.sh b/docker/dockerfiles/build.sh new file mode 100755 index 00000000..70daa946 --- /dev/null +++ b/docker/dockerfiles/build.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +if [ -z "$1" ]; then + echo "Please specify a version" + exit 1 +fi + +version="$1" +if [[ $version == v* ]]; then + version="${version:1}" +fi + +cd "$(dirname "$0")" + +echo "============ Building Tools ============" +docker build \ + --build-arg version=$version \ + --tag docspell/tools:v$version \ + --tag docspell/tools:latest \ + -f tools.dockerfile . + +echo "============ Building Restserver ============" +docker build \ + --build-arg version=$version \ + --tag docspell/restserver:v$version \ + --tag docspell/restserver:latest \ + -f restserver.dockerfile . + +echo "============ Building Joex ============" +docker build \ + --build-arg version=$version \ + --tag docspell/joex:v$version \ + --tag docspell/joex:latest \ + -f joex.dockerfile . diff --git a/docker/dockerfiles/joex-entrypoint.sh b/docker/dockerfiles/joex-entrypoint.sh new file mode 100755 index 00000000..3ed3df29 --- /dev/null +++ b/docker/dockerfiles/joex-entrypoint.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +echo "Starting unoconv listener" +unoconv -l & + +/opt/docspell-joex/bin/docspell-joex "$@" diff --git a/docker/dockerfiles/joex.dockerfile b/docker/dockerfiles/joex.dockerfile new file mode 100644 index 00000000..5a882732 --- /dev/null +++ b/docker/dockerfiles/joex.dockerfile @@ -0,0 +1,68 @@ +FROM alpine:latest + +ARG version= +ARG joex_url= +ARG UNO_URL=https://raw.githubusercontent.com/unoconv/unoconv/0.9.0/unoconv + +ENV JAVA_OPTS="-Xmx1536M" + +RUN apk add --no-cache openjdk11 \ + tzdata \ + bash \ + curl \ + ghostscript \ + tesseract-ocr \ + tesseract-ocr-data-deu \ + tesseract-ocr-data-fra \ + tesseract-ocr-data-ita \ + tesseract-ocr-data-spa \ + tesseract-ocr-data-por \ + tesseract-ocr-data-ces \ + tesseract-ocr-data-nld \ + tesseract-ocr-data-dan \ + tesseract-ocr-data-fin \ + tesseract-ocr-data-nor \ + tesseract-ocr-data-swe \ + tesseract-ocr-data-rus \ + tesseract-ocr-data-ron \ + tesseract-ocr-data-lav \ + unpaper \ + wkhtmltopdf \ + libreoffice \ + ttf-droid-nonlatin \ + ttf-droid \ + ttf-dejavu \ + ttf-freefont \ + ttf-liberation \ + libxml2-dev \ + libxslt-dev \ + pngquant \ + zlib-dev \ + g++ \ + qpdf \ + py3-pip \ + python3-dev \ + libffi-dev\ + qpdf-dev \ + openssl-dev \ + ocrmypdf \ + && pip3 install --upgrade pip \ + && pip3 install ocrmypdf \ + && curl -Ls $UNO_URL -o /usr/local/bin/unoconv \ + && chmod +x /usr/local/bin/unoconv \ + && apk del curl libxml2-dev libxslt-dev zlib-dev g++ python3-dev py3-pip libffi-dev qpdf-dev openssl-dev \ + && ln -s /usr/bin/python3 /usr/bin/python + +WORKDIR /opt +RUN wget ${joex_url:-https://github.com/eikek/docspell/releases/download/v$version/docspell-joex-$version.zip} && \ + unzip docspell-joex-*.zip && \ + rm docspell-joex-*.zip && \ + ln -snf docspell-joex-* docspell-joex + +COPY joex-entrypoint.sh /opt/joex-entrypoint.sh + +ENTRYPOINT ["/opt/joex-entrypoint.sh"] +EXPOSE 7878 + +HEALTHCHECK --interval=1m --timeout=10s --retries=2 --start-period=10s \ + CMD pgrep -f joex/lib diff --git a/docker/dockerfiles/restserver.dockerfile b/docker/dockerfiles/restserver.dockerfile new file mode 100644 index 00000000..78afeec1 --- /dev/null +++ b/docker/dockerfiles/restserver.dockerfile @@ -0,0 +1,18 @@ +FROM alpine:latest + +ARG version= +ARG restserver_url= + +RUN apk add --no-cache openjdk11 bash tzdata + +WORKDIR /opt +RUN wget ${restserver_url:-https://github.com/eikek/docspell/releases/download/v$version/docspell-restserver-$version.zip} && \ + unzip docspell-restserver-*.zip && \ + rm docspell-restserver-*.zip && \ + ln -snf docspell-restserver-* docspell-restserver + +ENTRYPOINT ["/opt/docspell-restserver/bin/docspell-restserver"] +EXPOSE 7880 + +HEALTHCHECK --interval=1m --timeout=10s --retries=2 --start-period=30s \ + CMD wget --spider http://localhost:7880 diff --git a/docker/dockerfiles/tools.dockerfile b/docker/dockerfiles/tools.dockerfile new file mode 100644 index 00000000..cb6b85ea --- /dev/null +++ b/docker/dockerfiles/tools.dockerfile @@ -0,0 +1,35 @@ +FROM alpine:latest + +# Builds an image where all scripts in tools/ are in PATH. There are +# no assumptions what script to run, so there are no CMD or +# ENTRYPOINTS defined. +# +# The scripts are named is in tools/ only prefixed by `ds-` +# +# Run the export-files script, for example: +# +# docker run -e DS_USER=demo -e DS_PASS=test docspell/tools:dev ds-export-files "http://localhost" . +# +# The build requires to either specify a version build argument or a +# tools_url build argument. If a tools_url argument is given, then +# this url is used to download the tools zip file. Otherwise the +# version argument is used to download from github. + +LABEL maintainer="eikek0 " + +ARG version= +ARG tools_url= + +RUN apk add --no-cache curl bash inotify-tools jq sqlite + +WORKDIR /opt +RUN wget ${tools_url:-https://github.com/eikek/docspell/releases/download/v$version/docspell-tools-$version.zip} && \ + unzip docspell-tools-*.zip && \ + rm docspell-tools-*.zip + +RUN bash -c 'while read f; do \ + target="ds-$(basename "$f" ".sh")"; \ + echo "Installing $f -> $target"; \ + cp "$f" "/usr/local/bin/$target"; \ + chmod 755 "/usr/local/bin/$target"; \ + done < <(find /opt/docspell-tools-* -name "*.sh" -mindepth 2 -not -path "*webextension*")'