Set up Avenvail OCR
Start the Avenvail OCR worker with Docker Compose or on its own, connect Avenvail to it, add languages and size its limits.
Avenvail OCR is a separate, optional container: ghcr.io/avenvail/avenvail-ocr, for amd64 and arm64. It holds Tesseract 5 with English (tessdata_fast), runs as a non-root user with a read-only filesystem, and answers only requests that carry its API key.
With Docker Compose
The official compose.yaml has the worker as the avenvail-ocr service in the ocr profile. It isn't published on a host port: only containers on the Compose network, such as Avenvail, reach it, at http://avenvail-ocr:8080.
Create an API key
Generate a long random value and add it to .env, with the host Avenvail may reach:
openssl rand -hex 32
AVENVAIL_OCR_TOKEN=paste-the-value-here
Avenvail__Outbound__AllowedHosts__0=avenvail-ocr
Avenvail refuses private network addresses by default, and ocr resolves to one; AllowedHosts allows that one host. If you already have AllowedHosts__0, use the next number. Instead, an admin can turn on Allow private network addresses on the connection itself; see Outside addresses only.
Start the worker
docker compose --profile ocr up -d
To start it with every docker compose up, without naming the profile, add COMPOSE_PROFILES=ocr to .env.
Connect Avenvail
In Automations › Connections, choose Add connection › Text recognition › Avenvail OCR. The address is filled in; paste the same API key, then Test.
The test checks that the worker answers, accepts the key, speaks the same protocol version as your Avenvail, has the default language, and reports its limits. A connection saves even when the worker is stopped; steps that use it fail until it's back.
On another machine
Run the worker anywhere Avenvail can reach, such as a machine with more processor cores:
docker run -d --name avenvail-ocr --restart unless-stopped \
--read-only --tmpfs /tmp:size=256m \
-e OCR_TOKEN=paste-the-value-here \
-p 127.0.0.1:8081:8080 \
ghcr.io/avenvail/avenvail-ocr:latest
Then set the connection's Worker address to where Avenvail reaches it, and allow that host with Avenvail__Outbound__AllowedHosts__0 if it's on a private network. Use the same version tag as Avenvail.
The worker speaks plain HTTP. Across machines, put it behind a reverse proxy with TLS (see Reverse proxy) or keep it on a private network, and never publish it to the internet without one: the API key is all that protects it. Any container runtime works; the worker needs only OCR_TOKEN and a writable /tmp.
Adding languages
Tesseract needs a .traineddata file per language, named by its code, such as deu for German or chi_sim for simplified Chinese. The worker never downloads them; add them in one of two ways.
Mount them. Download files from tessdata_fast, put them in a tessdata folder next to compose.yaml, and uncomment the volume in the avenvail-ocr service:
volumes:
- ./tessdata:/tessdata:ro
Build them in. Build the image with the languages you want:
docker build -f workers/ocr/Dockerfile --build-arg OCR_LANGUAGES="eng deu chi_sim" -t avenvail-ocr:local .
Restart the worker after either; the connection test and the step's Language then list the new languages.
Resources
The worker reads its limits from environment variables:
| Variable | Default | |
|---|---|---|
OCR_TOKEN | Required | The API key, at least 16 characters. |
OCR_CONCURRENCY | Half the processor cores, at least 1 | Images read at once. Others wait in line. |
OCR_QUEUE_SECONDS | 30 | How long a request waits for a free slot before the worker answers busy. Avenvail then retries. |
OCR_TIMEOUT_SECONDS | 50 | Longest time for one image. Tesseract is stopped when it runs over, or when Avenvail cancels. |
OCR_MAX_IMAGE_BYTES | 20971520 (20 MiB) | Largest image file. |
OCR_MAX_PIXELS | 40000000 | Largest image, in pixels, checked before decoding. |
OCR_MAX_SCALED_PIXELS | 60000000 | Largest image after enlarging. A preset enlarges less to stay under it. |
OCR_MAX_OUTPUT_BYTES | 16777216 | Largest result Tesseract may produce. |
OCR_MAX_TEMP_BYTES | 201326592 (192 MiB) | Room for prepared images at once; keep it under the /tmp size. |
Each image uses about four bytes per pixel of memory while it's prepared. With the defaults, plan for around 300 MiB per concurrent image at the largest sizes, and much less for screenshots. In Avenvail, the connection's Timeout and usage limits apply as for any connection, and the step gives up after 5 minutes.
The worker's API
The protocol is specific to OCR, at version 1. Every /v1 request needs Authorization: Bearer <OCR_TOKEN>.
| Request | Answers |
|---|---|
GET /health | ok, without a key. The image's health check uses it. |
GET /v1/manifest | id, version, protocol, engine, languages, presets, formats and limits. |
GET /v1/languages | The installed languages, as code and name. |
POST /v1/ocr | Reads the image in the body. Query: languages (eng+deu), preset (auto, screenshot, document, sparse), and optionally segmentation, scale, invert, threshold and timeout in seconds. Answers text, confidence, words, width, height, scale and durationMs. |
Errors are { "error": { "code", "message", "retryable" } }: unauthorized (401), request_invalid (400), image_too_large (413), image_invalid and language_unavailable (422), busy (503, retryable) and timeout (504). In Avenvail they become step errors starting with ocr_, such as ocr_language_unavailable.
Troubleshooting
| Problem | What to do |
|---|---|
| The test says Couldn't connect to the service. | Check the worker runs (docker compose --profile ocr ps) and the address. In Compose it's http://avenvail-ocr:8080. |
| The test says the address isn't allowed | Add the worker's host to Avenvail__Outbound__AllowedHosts__0, then restart Avenvail. |
| The worker refused the API key | The connection's API key must equal the worker's OCR_TOKEN. |
| The worker exits at start | docker compose logs avenvail-ocr. It needs AVENVAIL_OCR_TOKEN of at least 16 characters. |
| This worker doesn't have … | Add the language's data, or choose one the worker has. |
ocr_busy errors | Raise OCR_CONCURRENCY if the machine has cores to spare, or let the retries catch up. |
ocr_timeout on large images | Use a preset that enlarges less, set Scale to 1, or raise OCR_TIMEOUT_SECONDS. |
| Text is missed | Try another preset; for light text on dark, set Invert colors to On. |