feat(docker): substitute SINGLETON_* at container start instead of build-at-boot#270
Draft
andersliland wants to merge 1 commit into
Draft
feat(docker): substitute SINGLETON_* at container start instead of build-at-boot#270andersliland wants to merge 1 commit into
andersliland wants to merge 1 commit into
Conversation
…ild at boot
Bake the Vite bundle ONCE at image build time with sentinel placeholders
(`__MEILI_UI_REPLACE_SINGLETON_{MODE,HOST,API_KEY}__`) and substitute
the real values from the runtime environment via `sed` in the
entrypoint. Boot time drops from 2-5 min (full `vite build` on every
container start) to seconds. Secret rotation / rolling updates become
viable in production clusters.
Backwards-compatible: if `dist/` is empty the entrypoint falls back to
the previous build-at-start path, so non-Docker callers running
`scripts/cmd.sh` directly are unaffected.
Fixes eyeix#269
|
@andersliland is attempting to deploy a commit to the Eyeix Team on Vercel. A member of the Team first needs to authorize it. |
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.
Fixes #269.
Summary
__MEILI_UI_REPLACE_SINGLETON_{MODE,HOST,API_KEY}__).scripts/cmd.shsed-substitutes the realSINGLETON_*env values into the prebuiltdist/and runspnpm run preview.vite buildon every container start) to seconds.This makes secret rotation and rolling updates viable in production clusters: today, every
kubectl rollout restart(or anything that triggers a pod restart, like Stakater Reloader on a secret change) blocks readiness for the full build duration.Backwards compatibility
scripts/cmd.shfalls back to the previous build-at-start behavior whendist/is empty, so:scripts/post-build.js.scripts/cmd.shdirectly against a tree without a prebuiltdist/— unaffected.SINGLETON_MODE,SINGLETON_HOST,SINGLETON_API_KEY,BASE_PATH).The placeholder strings are unique sentinels (
__MEILI_UI_REPLACE_SINGLETON_*__) and follow the same pattern this repo already uses forMEILI_UI_REPLACE_BASE_PATH(seescripts/post-build.js).Safety net
If a placeholder slips through the
sedpass (e.g. the bundler emits an escaped form), the entrypoint exits non-zero rather than serve sentinel strings to the browser.Test plan
docker buildproduces adist/with placeholders.docker runwithSINGLETON_MODE=truesubstitutes correctly; the bundle no longer contains placeholder strings.docker runwith noSINGLETON_*set substitutes placeholders to empty (multi-instance mode).dist/from the image falls back to build-at-start path.Happy to iterate if a different approach (e.g. a
dist/config.jsruntime endpoint) is preferred — see linked issue for the alternative discussed.