From a1bf3957ba539eb1d7019c69e5d27aa41299c853 Mon Sep 17 00:00:00 2001 From: eikek Date: Mon, 25 Oct 2021 14:06:29 +0200 Subject: [PATCH] Change docker-compose to use env vars --- README.md | 4 +- docker/docker-compose/.env | 2 - docker/docker-compose/docker-compose.yml | 52 +++++++++--- docker/docker-compose/docspell.conf | 94 --------------------- website/elm/GetStarted.elm | 3 +- website/site/content/docs/install/docker.md | 39 ++++++--- website/site/content/docs/tools/cli.md | 3 +- 7 files changed, 73 insertions(+), 124 deletions(-) delete mode 100644 docker/docker-compose/.env delete mode 100644 docker/docker-compose/docspell.conf diff --git a/README.md b/README.md index d89d656c..4e7e6a48 100644 --- a/README.md +++ b/README.md @@ -58,8 +58,8 @@ away: ``` shell git clone https://github.com/eikek/docspell -cd docspell/docker -DOCSPELL_HEADER_VALUE="my-secret-123" docker-compose up +cd docspell/docker/docker-compose +docker-compose up -d ``` Then go to `http://localhost:7880`, sign up and login. Use the same diff --git a/docker/docker-compose/.env b/docker/docker-compose/.env deleted file mode 100644 index 7f5e39ae..00000000 --- a/docker/docker-compose/.env +++ /dev/null @@ -1,2 +0,0 @@ -TZ=Europe/Berlin -DOCSPELL_HEADER_VALUE=none diff --git a/docker/docker-compose/docker-compose.yml b/docker/docker-compose/docker-compose.yml index 84bf5979..bb4cdbd7 100644 --- a/docker/docker-compose/docker-compose.yml +++ b/docker/docker-compose/docker-compose.yml @@ -1,17 +1,35 @@ version: '3.8' services: + # The restserver and joex containers defined here are configured + # using env variables. Both must connect to the same database and + # solr instance. More information on configuring can be found here: + # https://docspell.org/docs/configure + # + # Please replace the values of the following with a custom secret + # string: + # + # - DOCSPELL_SERVER_ADMIN__ENDPOINT_SECRET + # - DOCSPELL_SERVER_AUTH_SERVER__SECRET + # - DOCSPELL_SERVER_INTEGRATION__ENDPOINT_HTTP__HEADER_HEADER__VALUE 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 + environment: + - DOCSPELL_SERVER_ADMIN__ENDPOINT_SECRET=admin123 + - DOCSPELL_SERVER_AUTH_SERVER__SECRET= + - DOCSPELL_SERVER_BACKEND_JDBC_PASSWORD=dbpass + - DOCSPELL_SERVER_BACKEND_JDBC_URL=jdbc:postgresql://db:5432/dbname + - DOCSPELL_SERVER_BACKEND_JDBC_USER=dbuser + - DOCSPELL_SERVER_BIND_ADDRESS=0.0.0.0 + - DOCSPELL_SERVER_FULL__TEXT__SEARCH_ENABLED=true + - DOCSPELL_SERVER_FULL__TEXT__SEARCH_SOLR_URL=http://docspell-solr:8983/solr/docspell + - DOCSPELL_SERVER_INTEGRATION__ENDPOINT_ENABLED=true + - DOCSPELL_SERVER_INTEGRATION__ENDPOINT_HTTP__HEADER_ENABLED=true + - DOCSPELL_SERVER_INTEGRATION__ENDPOINT_HTTP__HEADER_HEADER__VALUE=integration-password123 depends_on: - solr @@ -20,16 +38,29 @@ services: container_name: docspell-joex command: - -J-Xmx3G - - /opt/docspell.conf restart: unless-stopped - env_file: ./.env + environment: + - TZ=Europe/Berlin + - DOCSPELL_JOEX_BASE__URL=http://docspell-joex:7878 + - DOCSPELL_JOEX_BIND_ADDRESS=0.0.0.0 + - DOCSPELL_JOEX_FULL__TEXT__SEARCH_ENABLED=true + - DOCSPELL_JOEX_FULL__TEXT__SEARCH_SOLR_URL=http://docspell-solr:8983/solr/docspell + - DOCSPELL_JOEX_JDBC_PASSWORD=dbpass + - DOCSPELL_JOEX_JDBC_URL=jdbc:postgresql://db:5432/dbname + - DOCSPELL_JOEX_JDBC_USER=dbuser ports: - "7878:7878" - volumes: - - ./docspell.conf:/opt/docspell.conf depends_on: - solr + # The consumedir container watches a directory for files to upload + # to docspell restserver. This uses the `dsc` tool. For information + # on the available options, see `dsc --help`. + # https://github.com/docspell/dsc + # + # The value after `Docspell-Integration` must match the secret + # specified at the restserver via + # DOCSPELL_SERVER_INTEGRATION__ENDPOINT_HTTP__HEADER_HEADER__VALUE. consumedir: image: docspell/dsc:latest container_name: docspell-consumedir @@ -41,10 +72,9 @@ services: - "--delete" - "-ir" - "--header" - - "Docspell-Integration:$DOCSPELL_HEADER_VALUE" + - "Docspell-Integration:integration-password123" - "/opt/docs" restart: unless-stopped - env_file: ./.env volumes: - ./docs:/opt/docs depends_on: diff --git a/docker/docker-compose/docspell.conf b/docker/docker-compose/docspell.conf deleted file mode 100644 index 963d3ed9..00000000 --- a/docker/docker-compose/docspell.conf +++ /dev/null @@ -1,94 +0,0 @@ -# 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/solr/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} - } - } - - # This is a special endpoint that allows some basic administration. - # - # This is used for some endpoints, for example: - # - re-create complete fulltext index: - # curl -XPOST -H'Docspell-Admin-Secret: xyz' http://localhost:7880/api/v1/admin/fts/reIndexAll - admin-endpoint { - # The secret. If empty, the endpoint is disabled. - secret = "" - } - - # 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/website/elm/GetStarted.elm b/website/elm/GetStarted.elm index 3779c0ff..95ad512c 100644 --- a/website/elm/GetStarted.elm +++ b/website/elm/GetStarted.elm @@ -25,8 +25,7 @@ getStarted version = 3. Run `docker-compose up`: ```bash - $ export DOCSPELL_HEADER_VALUE="my-secret-123" - $ docker-compose up + $ docker-compose up -d ``` The environment variable defines a secret that is shared between diff --git a/website/site/content/docs/install/docker.md b/website/site/content/docs/install/docker.md index 4dcd6ee9..abb4aa0e 100644 --- a/website/site/content/docs/install/docker.md +++ b/website/site/content/docs/install/docker.md @@ -172,18 +172,25 @@ $ cd docspell/docker/docker-compose Then run `docker-compose`: ```bash -$ export DOCSPELL_HEADER_VALUE="my-secret-123" -$ docker-compose up +$ docker-compose up -d ``` -The environment variable defines a secret that is shared between the -container watching a directory and the server. It is the header -defined for the [integration -endpoint](@/docs/api/upload.md#integration-endpoint) containers. You -can use whatever you like. Please see the help to the [dsc -tool](@/docs/tools/cli.md) docs for additional info. +If you look at `docker-compose.yml`, there are several environment +variables defined. A few that you should change, i.e. all "secrets": -Goto `http://localhost:7880`, signup and login. When signing up, you +- `DOCSPELL_SERVER_ADMIN__ENDPOINT_SECRET` +- `DOCSPELL_SERVER_AUTH_SERVER__SECRET` +- `DOCSPELL_SERVER_INTEGRATION__ENDPOINT_HTTP__HEADER_HEADER__VALUE` + +Then, the value for +`DOCSPELL_SERVER_INTEGRATION__ENDPOINT_HTTP__HEADER_HEADER__VALUE` +must be duplicated in the consumedir command (both values must match). +It is the header defined for the [integration +endpoint](@/docs/api/upload.md#integration-endpoint). You can use +whatever you like, best something random. Please see the help to the +[dsc tool](@/docs/tools/cli.md) docs for additional info. + +Goto `http://localhost:7880`, signup and login. When signing up, choose the same name for collective and user. Then login with this name and the password. @@ -191,9 +198,19 @@ name and the password. chose for the collective at registration) and place files in there for importing them. -The directory contains a file `docspell.conf` that you can -[modify](@/docs/configure/_index.md) as needed. +Docspell can be configured via environment variables or a config file. +Please see the [configuration](@/docs/configure/_index.md) for more +details and possible values/variables. You can create a config file +and mount it into the container. Then specify the config file as the +an argument to the command, i.e. add a +``` yml +command: + - /path/to/config.conf +``` + +to the service definition (or add it to an existing `command:` +section). ### Override this setup diff --git a/website/site/content/docs/tools/cli.md b/website/site/content/docs/tools/cli.md index fcf3836c..7f8a207b 100644 --- a/website/site/content/docs/tools/cli.md +++ b/website/site/content/docs/tools/cli.md @@ -429,8 +429,7 @@ defining an environment variable which gets picked up by the containers defined in `docker-compose.yml`: ``` bash -export DOCSPELL_HEADER_VALUE="my-secret" -docker-compose up +docker-compose up -d ```