Skip to content

web-app-serve: helm wrapper chart + harden apply-config - #91

Open
thenav56 wants to merge 4 commits into
mainfrom
feat/web-app-serve-helm
Open

web-app-serve: helm wrapper chart + harden apply-config#91
thenav56 wants to merge 4 commits into
mainfrom
feat/web-app-serve-helm

Conversation

@thenav56

@thenav56 thenav56 commented Jul 17, 2026

Copy link
Copy Markdown
Member

Changes

ci: — publish helm wrapper chart via web-app-serve-action@v0.2.0

The web-app-serve Docker image path is already integrated upstream; this adds
the Helm wrapper chart so CI publishes both the image and a deployable chart.

  • Workflow renamed publish-web-app-serve.ymlhelm-publish.yaml; action bumped v0.1.1v0.2.0 (helm-capable, helm_publish: true); permissions widened with contents: read + pull-requests: read (the provenance writer resolves the PR from the commit) alongside the existing packages: write. Real trigger branches (develop, project/*) kept.
  • New wrapper chart web-app-serve/helm/ (mapswipe-web-helm), depending on oci://ghcr.io/toggle-corp/web-app-serve-helm:0.2.1 aliased app. Minimal values.yaml nests everything under app: with SET-BY-CICD image placeholders and a pre-seeded ingress.annotations: {}. CI stamps the image name/tag + provenance annotations and pushes the chart to GHCR on every push.
  • web-app-serve/helm/.gitignore excludes the helm dependency update artifacts (charts/, Chart.lock); CI regenerates them.

fix: — harden the custom ^VITE_ apply-config

The runtime apply-config (web-app-serve/web-app-apply-config.sh) had no
hardening. It is now brought in line with the current convention:

  • Escape sed replacement metacharacters (\, &, |) so URLs/tokens with them substitute literally instead of corrupting output or exiting the container.
  • Drop the old ${VALUE:-undefined} quirk (it injected the truthy string "undefined" into quoted JS defines only for set-but-empty vars); set-but-empty now substitutes to an empty value.
  • After substitution, warn (stderr) about every leftover WEB_APP_SERVE_PLACEHOLDER__VITE_* marker, then rewrite the quoted-JS markers to bare undefined (falsy) so an omitted optional var no longer leaks a truthy marker into the bundle.
  • Bake VITE_ALLOW_UNVERIFIED_USERS=true as an overridable default ENV in the Dockerfile final stage: overrideDefineForWebAppServe emits an unquoted marker for the one Schema.boolean key, which the quoted-JS rewrite cannot blank — without a baked default an unset runtime would leave a bare-identifier ReferenceError. Deployments can still override it. (Preserves the value the build stage already baked; flip to false at deploy time if unverified users should be disallowed.)

Verification

  • Local helm check: helm dependency update + helm lint + helm template (with the deploy-time --set app.ingress.hostname/ingressClassName/image.name flags) all pass.
  • apply-config validator (VITE_): 7/7 pass.
  • Docker bare-run leak check: 0 unreplaced markers; &/| values substitute literally; unset optional vars resolve to undefined with a stderr warning; VITE_ALLOW_UNVERIFIED_USERS substitutes to a bare true.

TODO before/after merge

  • Remove the temporary feat/web-app-serve-helm entry from on.push.branches in .github/workflows/helm-publish.yaml — it exists only to test the publish workflow end-to-end on this branch (the slash in the branch name publishes to ghcr.io/mapswipe/mapswipe-web-dev / mapswipe-web-dev-helm).

thenav56 added 4 commits July 17, 2026 22:40
Migrate the web-app-serve publish workflow to also publish a Helm wrapper
chart (docker image path already integrated upstream):

- Rename publish-web-app-serve.yml -> helm-publish.yaml.
- Bump toggle-corp/web-app-serve-action v0.1.1 -> v0.2.0 (helm-capable) and
  set helm_publish: true.
- Grant contents: read and pull-requests: read (the provenance writer resolves
  the PR from the commit); keep packages: write.
- Add web-app-serve/helm wrapper chart depending on web-app-serve-helm 0.1.1
  (aliased app), with SET-BY-CICD image placeholders and pre-seeded
  ingress.annotations.

Temp branch trigger (feat/web-app-serve-helm) added to exercise the workflow;
remove after merge.
…ed placeholders resolve to JS undefined + warn)

The custom ^VITE_ apply-config had no hardening: no sed metacharacter
escaping, and a ${VALUE:-undefined} default that only affected set-but-empty
vars (injecting the truthy string "undefined" into quoted JS defines) while
leaving omitted vars leaking the literal placeholder marker.

Rewrite it to mirror the helix-client reference (adapted to VITE_):
- Escape sed replacement metachars (\, &, |) so URLs/tokens substitute
  literally instead of corrupting output or exiting the container.
- Drop the :-undefined quirk; set-but-empty now substitutes to an empty value.
- After the substitution loop, warn (stderr) about every leftover
  WEB_APP_SERVE_PLACEHOLDER__VITE_* marker, then rewrite the quoted-JS markers
  to bare 'undefined' (falsy) so an omitted optional var no longer leaks a
  truthy marker into the bundle.

overrideDefineForWebAppServe emits an UNQUOTED marker for the one
Schema.boolean key (VITE_ALLOW_UNVERIFIED_USERS), which the quoted-JS rewrite
cannot blank; bake it as an overridable default ENV in the Dockerfile final
stage so the substitution loop always fills it (avoids a bare-identifier
ReferenceError on an unset runtime).

Verified: validator (VITE_) passes; docker bare-run leak check reports 0
markers; &/| substitute literally; unset optional vars resolve to undefined
with a stderr warning.
Comment thread Dockerfile
# `WEB_APP_SERVE_PLACEHOLDER__VITE_ALLOW_UNVERIFIED_USERS` identifier (ReferenceError).
# Baking a default here means the substitution loop always fills it; deployments
# can still override it at runtime.
ENV VITE_ALLOW_UNVERIFIED_USERS=true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be "false" by default?

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.

2 participants