Changelog - 2026-10-22
Runtime config in the app preset, one image for every environment
New FeatureNOTE
Since ARDOR 0.4.7, getRuntimeConfig is RuntimeConfig.get, with the same arguments and the same result. The code samples below use the old name. See Utilities move to classes.
In one line. An app made by vulcan init --preset ardor reads its API address when the container starts, so one built image runs in every environment, and it can refuse to start when a variable it needs is missing.
What changed
config.jsat container start. The image writes/config.jsfrom the container's environment variables that start withVITE_, andindex.htmlloads it before the app.docker run -e VITE_API_URL=https://api.example.com imageis enough.getRuntimeConfig.@venizia/ardor-kernel(and@venizia/ardor) exportgetRuntimeConfig({ key, buildTimeEnv, defaultValue }): the value fromconfig.js, else the build-time one you pass (import.meta.env), else the default. The preset uses it forVITE_API_URL, the address the REST data provider calls (default/api).- Safe by default. Only
VITE_variables are published, every value is escaped, aVITE_name withSECRET,PASSWORDorTOKENstops the container, andconfig.jsis never cached. AVITE_value is public: every visitor can read it. - Required variables.
APP_REQUIRED_ENVis a comma-separated list of names, for exampleVITE_API_URL,API_UPSTREAM. Set it in the Dockerfile withENV APP_REQUIRED_ENV="VITE_API_URL,API_UPSTREAM", or pass-e APP_REQUIRED_ENV=...for one environment. A listed variable that is unset or empty stops the container with exit code 1, instead of falling back to a build-time value, and noconfig.jsis written. - A clear message. It names every missing variable at once, in your order, and never prints a value:
[runtime-config] FATAL: required variable(s) missing or empty: VITE_API_URL, VITE_MAPS_KEY. - Any name. You can require a variable that is not published, such as
API_UPSTREAM. Spaces around a name and empty entries are ignored. An entry that is not a variable name stops the container, and the message gives its position in the list. .env.examplelistsVITE_API_URL, and the Dockerfile carries a commentedAPP_REQUIRED_ENVline to uncomment. Nothing is required by default.
Who is affected
- A new app. It has the runtime config. No action needed.
- An app already generated from the preset. Nothing changes. To get it, copy
.configs/builders/docker-entrypoint.d/40-runtime-config.sh,src/public/config.js, theconfig.jsscript tag ofsrc/index.html, thelocation = /config.jsblock of the nginx template and theCOPY --chmod=0755line of the Dockerfile. To use the required-variable check, also add theENV APP_REQUIRED_ENVline to the Dockerfile. - An app that writes its own
config.js(for example from adocker-entrypoint.dscript): it can keep it, or read it withgetRuntimeConfigif the global is namedwindow.__APP_CONFIG__. - A mounted
config.js. A read-only file that an operator mounts overconfig.jsis kept as it is, and the listed variables are not checked, because the operator supplied the configuration.