Skip to content

make update: content-digest cache buster for VITE_* changes - #12

Merged
MostafaMoradii merged 1 commit into
mainfrom
feat/web-env-digest-cachebust
Jun 30, 2026
Merged

MostafaMoradii merged 1 commit into
mainfrom
feat/web-env-digest-cachebust

Conversation

@MostafaMoradii

Copy link
Copy Markdown
Collaborator

Summary

Operators edit apps/web/.env, run make update, and see the SPA still shipping the old VITE_* values. The Dockerfile's ARG-based cache invalidation isn't reliable enough on its own.

Fix by adding a content-digest cache buster:

  • scripts/updater.sh hashes apps/web/.env + repo-root .env and exports WEB_ENV_DIGEST.
  • docker-compose.yml threads it as a build arg on the web service.
  • web.Dockerfile consumes the ARG just before the pnpm build RUN.

Any byte change in either env file produces a different digest → BuildKit invalidates the pnpm build layer reliably → Vite re-inlines the current VITE_* values.

The pnpm-store --mount=type=cache keeps install fast, so the rebuild cost is ~30-60s — the price of make update always doing what it says.

Test plan

  • On prod: edit apps/web/.env (change VITE_CONSOLE_BASE_URL or just touch the file), run make update, confirm the build output shows web env digest: <newhash>... and the pnpm build layer re-runs (no CACHED marker).
  • Re-running make update without editing reuses the layer (the digest matches → cache hit).
  • Existing console-url tests pass.

The previous chain — operator edits apps/web/.env → make update →
docker compose build — relied on BuildKit invalidating the `pnpm
build` layer when an ARG value changed. That works in theory but
isn't reliable enough in practice: operators were seeing stale
bundles ship after env edits, with no other way out than a manual
`docker compose build --no-cache web`.

Add a content-digest cache buster:
- scripts/updater.sh hashes apps/web/.env + repo-root .env, exports
  WEB_ENV_DIGEST.
- docker-compose.yml threads it as a build arg.
- web.Dockerfile consumes it just before the `pnpm build` RUN.

Any byte change in either env file produces a different digest →
the build layer invalidates → Vite re-inlines the current VITE_*
values. The pnpm-store mount cache keeps `pnpm install` fast, so
the rebuild cost stays at ~30-60s.
@MostafaMoradii
MostafaMoradii merged commit 0631da9 into main Jun 30, 2026
@MostafaMoradii
MostafaMoradii deleted the feat/web-env-digest-cachebust branch June 30, 2026 17:56
MostafaMoradii added a commit that referenced this pull request Jun 30, 2026
…-zone times

Three small README updates reflecting recent shipped behavior:

1. VITE_CONSOLE_BASE_URL / VITE_WS_URL examples now show the bare-host
   form first (after PR #11, the SPA normalizes both shapes to the
   same final URL).

2. Drop the "if the SPA still hits :8090, force --no-cache" callout —
   PR #12's content-digest cache buster means a make update after any
   apps/web/.env edit reliably picks up the new values.

3. Add a paragraph in 'What's where' noting that times render in the
   operator's local zone with a ±HH:MM offset suffix on the hover
   tooltip (the convention that landed today).
MostafaMoradii added a commit that referenced this pull request Jun 30, 2026
PR #12's cache-buster called sha256sum unconditionally, which is GNU
coreutils. macOS dev laptops have shasum -a 256 instead, so the
command failed under set -euo pipefail and the whole build aborted
with an opaque 'building: server web' line and nothing else:

    ==> building: server web
    make: *** [update] Error 1

Probe PATH, pick whichever hasher exists, use awk for the field
extract (gnu cut vs bsd cut differ in flag handling for piped input
in older versions). If neither is present, log a warning and skip
the cache-buster — the operator can still run with manual --no-cache
on the rare boxes that have neither tool.
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.

1 participant