Skip to content

Configuration

The configuration via the YAML file has been introduced in the 7.1 Document Reader SDK release, and from that moment, it's the preferred variant of the service configuration. The configuration via environment variables is considered deprecated for the most cases with rare exception, considered further.

The YAML file holds the map of key-value pairs, organized into a tree-like hierarchical structure. This type of configuration gives an ability to keep all the product-specific parameters in one place and change any of them (or all at once) without cluttering the global variables' workspace.

Deprecated

For information about configuring the Web Service via environment variables, see the Environment Variables page.

To transfer your current existing Web Service configuration from environment variables to the YAML file, see the Migration Guide.

Order of Precedence

The universal order of precedence for all configuration options of the Web Service is as follows:

  1. Parameters in the config.yaml file, see How to Enable YAML Config
  2. Environment variables in the .env file
  3. Environment variables in the OS
  4. Built-in defaults

Also, there are two exceptions. For security reasons, these parameters operate differently:

Environment variable YAML parameter
AZURE_STORAGE_CONNECTION_STRING service.storage.az.connectionString
SQL_CONNECTION_STRING service.database.connectionString

For them, the order of precedence is the following:

  1. Environment variables in OS
  2. Environment variables in the .env file
  3. Parameters in the config.yaml file

Enable YAML Configuration

To activate the YAML configuration for the Web Service, follow the steps:

  1. In the Web Service root directory find the config.yaml.example file and rename it to config.yaml
  2. Populate the config.yaml file with proper values.
  3. Define the DOCREADER_CONFIG_PATH environment variable with the corresponding path to the config.yaml configuration file:
DOCREADER_CONFIG_PATH="/path/to/config.yaml"

Notes:

  • For Docker, all relative paths are subpaths to the installation folder or /app/folder
  • It's recommended to always use absolute paths to folders and resource files: master lists directory (for RFID), logs, licenses, etc.

Example

Below, see the contents' example of the config.yaml file or download it.

config.yaml
service:
  webServer:
    port: 8080
    workers: 1
    timeout: 30

    demoApp:
      enabled: true

    cors:
      origins: "*"
      headers: "Content-Type"
      methods: "POST,PUT,GET,DELETE,PATCH,HEAD"

    ssl:
      enabled: false
      cert: certs/tls.crt
      key: certs/tls.key
      tlsVersion: 1.2

    logging:
      level: INFO
      formatter: text

      access:
        console: true
        path: logs/docreader-access.log

      app:
        console: true
        path: logs/docreader-app.log

If you use Docker Compose, you can mount the config.yaml in the docker-compose.yml file. See the example below or download it.

docker-compose.yml
version: "3.7"

services:
  docreader:
    container_name: docreader
    image: regulaforensics/docreader:latest
    volumes:
      - ./regula.license:/app/extBin/unix/regula.license
      - ./config.yaml:/app/config.yaml
    networks:
      - docreader-network
    healthcheck:
      test: curl -f http://127.0.0.1:8080/api/ping
      interval: 60s
      start_period: 60s
      timeout: 30s
      retries: 5
    ports:
      - "8080:8080"

networks:
  docreader-network:
    driver: bridge

To start the Docker container, invoke:

sudo docker-compose up -d

To stop the Docker container, run:

sudo docker-compose down

To delete data after stopping the Docker container, run:

sudo docker-compose down -v