From 3d902c3273c8129d97bf5b5ce0f259cdcd28bb7a Mon Sep 17 00:00:00 2001 From: Eike Kettner Date: Mon, 25 May 2020 19:43:06 +0200 Subject: [PATCH] Add a docker image for watching a directory --- docker/consumedir.dockerfile | 15 +++++++++++++ docker/docker-compose.yml | 11 ++++++++++ .../microsite/docs/doc/tools/consumedir.md | 22 +++++++++++++++++++ modules/microsite/docs/getit.md | 9 ++++++++ 4 files changed, 57 insertions(+) create mode 100644 docker/consumedir.dockerfile diff --git a/docker/consumedir.dockerfile b/docker/consumedir.dockerfile new file mode 100644 index 00000000..6b0fd13c --- /dev/null +++ b/docker/consumedir.dockerfile @@ -0,0 +1,15 @@ +FROM alpine:latest + +LABEL maintainer="eikek0 " + +RUN apk add --no-cache unzip curl bash inotify-tools + +RUN mkdir -p /opt \ + && cd /opt \ + && curl -L -o docspell.zip https://github.com/eikek/docspell/releases/download/v0.6.0/docspell-tools-0.6.0.zip \ + && unzip docspell.zip \ + && rm docspell.zip \ + && apk del unzip \ + && chmod 755 /opt/docspell-tools-0.6.0/*.sh + +ENTRYPOINT ["/opt/docspell-tools-0.6.0/consumedir.sh"] diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index e6eda62d..ce28eb03 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -29,5 +29,16 @@ services: - ${PWD}/docspell.conf:/opt/docspell.conf depends_on: - db + consumedir: + image: eikek0/docspell:consumedir-0.6.0 + container_name: docspell-consumedir + command: --path /opt/docs -m http://restserver:7880/api/v1/open/upload/item/$SOURCE_ID + environment: + - SOURCE_ID=${SOURCE_ID:-none} + volumes: + - ${PWD}/docs:/opt/docs + depends_on: + - restserver + volumes: postgres_data: diff --git a/modules/microsite/docs/doc/tools/consumedir.md b/modules/microsite/docs/doc/tools/consumedir.md index d686a7da..f95fff0c 100644 --- a/modules/microsite/docs/doc/tools/consumedir.md +++ b/modules/microsite/docs/doc/tools/consumedir.md @@ -62,3 +62,25 @@ This unit file is just an example, it needs some fiddling. It assumes an existing user `someuser` that is used to run this service. The url `http://localhost:7880/api/v1/open/upload/...` is an anonymous upload url as described [here](../uploading#anonymous-upload). + + +## Docker + +The provided docker image runs this script to watch a directory for +new files. If a new file is detected, it is pushed to docspell. + +For this to work, the container must know about a valid upload url. +Therefore, you must first signup and create such an upload url, as +described [here](doc/uploading#anonymous-upload). Get only the id +(something like `AvR6sA8GKFm-hgYDgZfwzXa-Tqnu8yqyz6X-KzuefvEvrRf`) and +define an environment variable `SOURCE_ID` with that value before +running `docker-compose up` a second time. + +``` +export SOURCE_ID="AvR6sA8GKFm-hgYDgZfwzXa-Tqnu8yqyz6X-KzuefvEvrRf" +docker-compose up +``` + +Now you can create a folder `./docs` and place all files in there that +you want to import. Once dropped in this folder the `consumedir` +container will push it to docspell. diff --git a/modules/microsite/docs/getit.md b/modules/microsite/docs/getit.md index 1e08bec1..03069279 100644 --- a/modules/microsite/docs/getit.md +++ b/modules/microsite/docs/getit.md @@ -91,3 +91,12 @@ available in the `/docker` folder. The directory contains a file `docspell.conf` that you can [modify](doc/configure) as needed. + + +### Watching files in a directory + +This setup starts a container running the +[`consumedir.sh`](doc/tools/consumedir) script. It is configured to +watch one directory and upload files arriving in there to docspell. +Please see the [`consumedir.sh`](doc/tools/consumedir#docker) docs for +additional steps.