Rework docker setup

This commit is contained in:
eikek 2021-05-31 00:07:11 +02:00
parent c0402b1f92
commit b122d9eab0
8 changed files with 326 additions and 0 deletions

View File

@ -0,0 +1,2 @@
TZ=Europe/Berlin
DOCSPELL_HEADER_VALUE=none

View File

@ -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:

View File

@ -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
}
}

34
docker/dockerfiles/build.sh Executable file
View File

@ -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 .

View File

@ -0,0 +1,6 @@
#!/bin/sh
echo "Starting unoconv listener"
unoconv -l &
/opt/docspell-joex/bin/docspell-joex "$@"

View File

@ -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

View File

@ -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

View File

@ -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 <eike@docspell.org>"
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*")'