Repository navigation
feat: read UI API and auth config at container start [#236] - #50
Open
hariharanweb wants to merge 2 commits into
Open
hariharanweb wants to merge 2 commits into
hariharanweb wants to merge 2 commits into
Conversation
- config.js (window.__ENV__) rendered from container env by /docker-entrypoint.d/40-runtime-config.sh; a mounted config.js is kept - UI reads window.__ENV__ first, falls back to build-time VITE_* values - API_BASE, AUTH_ENABLED, KEYCLOAK_*, DOCUMENT_VALIDITY_ENABLED are runtime; VITE_BASE stays a build arg - compose builds for /knowledge-provider/, matching what the image serves - ADR 0008 and ENV.md document the runtime vars Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
- .env.example: API/auth/Keycloak/validity are runtime (restart ui); VITE_BASE stays a build arg; add VITE_DOCUMENT_VALIDITY_ENABLED - ui/.env.example: note the production image takes these as container env Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of OpenAgriNet/engineering-tracker#236 (deploying KP to K8s): one UI image for every environment, configured with env vars instead of rebuilds.
What changes
/docker-entrypoint.d/40-runtime-config.shrenders/knowledge-provider/config.js(window.__ENV__) from container env. If aconfig.jsis mounted (e.g. a ConfigMap), it is kept as is.ui/src/runtimeEnv.jsgetEnv()readswindow.__ENV__first, then the build-timeVITE_*value.config.jsandauth/keycloak.jsread through it.API_BASE,AUTH_ENABLED,KEYCLOAK_URL,KEYCLOAK_REALM,KEYCLOAK_CLIENT_ID,KEYCLOAK_IDP_HINT,DOCUMENT_VALIDITY_ENABLED.VITE_BASEstays a build arg.config.jswithCache-Control: no-store.npm run devis unchanged (ui/public/config.jsis an emptywindow.__ENV__).Behaviour changes to note
/docs-pipeline/, but the image only serves/knowledge-provider/. It now builds for/knowledge-provider/.scripts/export-prod-images.shno longer bakes in the production Keycloak values; set them as container env per deployment.DOCUMENT_VALIDITY_ENABLEDdefaults totrue, matching the previousDockerfile.proddefault..env.example/ui/.env.examplemark which UI vars are runtime and which are build-time;VITE_DOCUMENT_VALIDITY_ENABLEDadded to the root example.Docs:
docs/ADR/0008-ui-config-at-container-start.md,ENV.md.Testing
npm test: 29 passed, including newruntimeEnvtests.npm run buildand eslint clean.-e API_BASE=/env-a-api -e AUTH_ENABLED=true: the servedconfig.jshad those values andCache-Control: no-store; the startup log shows40-runtime-config.shrunning after nginx's own scripts.config.jsis kept, a generated one is regenerated with new env, and a directory at the target path exits 1. Not tested with a real-vmount.docker compose -f docker-compose.yml configshows the new env onui.🤖 Generated with Claude Code