Skip to content

Comments

Add env vars to docker addons#3274

Open
tiborrr wants to merge 12 commits intoeikek:masterfrom
tiborrr:add-env-vars-to-docker-addons
Open

Add env vars to docker addons#3274
tiborrr wants to merge 12 commits intoeikek:masterfrom
tiborrr:add-env-vars-to-docker-addons

Conversation

@tiborrr
Copy link
Contributor

@tiborrr tiborrr commented Feb 23, 2026

Add support for addon-specific environment variables

Closes #2896

Summary

Add server-level configuration to inject custom environment variables into addons. Configs are keyed by addon name and support direct values or reading from the process environment.

Configuration

docspell.joex.addons {
  configs = [
    {
      name = "my-postgres-addon"
      enabled = true
      envs = [
        { name = "POSTGRES_HOST", value = "localhost" }
        { name = "POSTGRES_PASSWORD", value-from = { env = "DS_POSTGRES_PASSWORD", optional = true } }
      ]
    }
  ]
}
  • value: literal string
  • value-from: read from process env. env = source variable name; optional (default: true) — when source unset: true = skip, false = inject empty string

Environment variable override

DOCSPELL_JOEX_ADDONS_CONFIGS_0_NAME="my-postgres-addon"
DOCSPELL_JOEX_ADDONS_CONFIGS_0_ENVS_0_NAME="POSTGRES_HOST"
DOCSPELL_JOEX_ADDONS_CONFIGS_0_ENVS_0_VALUE="localhost"

Running example

Use docspell-addon-example — it logs all DOCSPELL_TEST_* env vars to stderr.

Used config:

# Development config - picked up by sbt when present
# Binds to 0.0.0.0 so the app is reachable from Windows when running in WSL2

docspell.server {
  bind {
    address = "0.0.0.0"
    port = 7880
  }
  backend {
    addons {
      enabled = true
      allow-impure = true
      allowed-urls = "*"
      denied-urls = ""
    }
  }
}

docspell.joex {
  bind {
    address = "0.0.0.0"
    port = 7878
  }
  addons {
    # Example: inject env vars for docspell-addon-example (prints DOCSPELL_TEST_* to stderr)
    configs = [
      {
        name = "docspell-addon-example"
        enabled = true
        envs = [
          { name = "DOCSPELL_TEST_FOO", value = "bar" }
          # value-from: read from process env (e.g. export DS_TEST_BAZ=secret before starting joex)
          { name = "DOCSPELL_TEST_BAZ", value-from = { env = "DS_TEST_BAZ", optional = true } }
        ]
      }
    ]
  }
}
image image image

Tibor Casteleijn and others added 12 commits February 23, 2026 12:04
- Add AddonConfig, AddonEnvVar, AddonEnvVarFrom case classes
- Extend AddonEnvConfig with configs: List[AddonConfig]
- Add configs = [] to docspell.joex.addons in reference.conf
- Add HOCON parsing tests for AddonConfig and AddonEnvConfig

Co-authored-by: Cursor <cursoragent@cursor.com>
- Add AddonEnvVar.resolve (value, valueFrom.env, optional)
- Add AddonConfig.toEnv for enabled configs
- Add tests for resolve and toEnv

Co-authored-by: Cursor <cursoragent@cursor.com>
- Add addonEnvResolver: String => Env to AddonExecutor
- Merge config env in runAddon before runner.run
- Build resolver from cfg.configs in AddonOps.getExecutor
- Add inject env vars test in AddonExecutorTest

Co-authored-by: Cursor <cursoragent@cursor.com>
Use tuple discard for task dependencies to avoid 'pure expression
does nothing in statement position' compiler warning.

Co-authored-by: Cursor <cursoragent@cursor.com>
Verify DOCSPELL_JOEX_ADDONS_CONFIGS_* override works in EnvConfigTest

Co-authored-by: Cursor <cursoragent@cursor.com>
- Expand reference.conf comment with example and value/value-from
- Add Environment variables section to addons control docs

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for addon-specific environment variables and secrets management

1 participant