| features |
|
|||||
|---|---|---|---|---|---|---|
| languages |
|
This example demonstrates how to dynamically template Aidbox init bundles using environment variables in Docker Compose by overriding the container entrypoint.
-
Template file:
init-bundle.json.tplcontains placeholders for environment variables (e.g.,${INIT_BUNDLE_CLIENT_ID}) -
Docker Compose override: The
docker-compose.yamlfile:- Mounts the template file into the container
- Overrides the default entrypoint to run
envsubstbefore starting Aidbox - Substitutes environment variables into the template, creating the final
init-bundle.json
-
Entrypoint rewriting: Instead of using the default Aidbox entrypoint, we override it with a custom shell script that:
entrypoint: - /bin/sh - -c - | envsubst < /tmp/init-bundle.json.tpl > /tmp/init-bundle.json /aidbox.sh
This runs
envsubstto process the template, then executes the original Aidbox entrypoint script. -
Environment variables: Set in the
environmentsection and used byenvsubst:INIT_BUNDLE_CLIENT_ID: Client ID for the init bundleINIT_BUNDLE_CLIENT_SECRET: Client secret for the init bundle
docker-compose upThe init bundle will be created with the values from the environment variables defined in docker-compose.yaml.