Skip to content

fix(aros-web): reproducible build with Supabase baked in (+ fail-loud guard)#10

Merged
Nirpat3 merged 3 commits into
mainfrom
fix/aros-web-supabase-build-guard
Jun 26, 2026
Merged

fix(aros-web): reproducible build with Supabase baked in (+ fail-loud guard)#10
Nirpat3 merged 3 commits into
mainfrom
fix/aros-web-supabase-build-guard

Conversation

@Nirpat3

@Nirpat3 Nirpat3 commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Why

app.aros.live login showed a blank white page: the served apps/web bundle called createClient("","") because VITE_SUPABASE_URL/VITE_SUPABASE_ANON_KEY were empty at build time, so the Supabase client threw supabaseUrl is required at module load and React never mounted.

Root cause: Vite inlines VITE_* env at build time, but the image build had no .env in context and passed no build-args, so empty strings got baked in.

What

apps/web/vite.config.ts:

  • loadEnv(mode, envDir, '') so the unprefixed SUPABASE_URL/SUPABASE_ANON_KEY the servers already provide are also picked up (Vite only auto-exposes VITE_*).
  • define{} inlines only the two public keys — never SUPABASE_SERVICE_ROLE_KEY (verified it does not leak into the bundle).
  • Fails the build if either is empty, turning a silent blank-page deploy into a loud build error.

Verified locally: guard fires on empty env; unprefixed vars inline correctly; service-role key absent from bundle.

Still needed (infra, not in this PR)

The image-build pipeline (deploy-aros-prod.ymlghcr.io/shreai/shreai/aros) must make SUPABASE_URL+SUPABASE_ANON_KEY available at build time (build-args or .env in context). With this guard, that build will now fail loudly until it does, instead of shipping a blank app.

🤖 Generated with Claude Code

Nirav Patel and others added 2 commits June 25, 2026 17:18
The web build inlines VITE_SUPABASE_URL/ANON_KEY at build time. CI builds
without them (no .env in context, no build-args), producing a bundle that
calls createClient("","") -> throws "supabaseUrl is required" at module
load -> React never mounts -> blank white page (the app.aros.live login
outage).

- loadEnv with empty prefix so the unprefixed SUPABASE_*/ANON_KEY the
  servers already provide are picked up (Vite only auto-exposes VITE_*).
- define{} inlines ONLY the two public keys (never SUPABASE_SERVICE_ROLE_KEY).
- Fail the build if either is empty, so a misconfigured build errors loudly
  instead of silently shipping a blank app.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Adds a self-contained, parameterized build for ghcr.io/shreai/shreai/aros
so the customer web app can't ship a blank-page bundle again:

- deploy/web-server.mjs: the tiny static server (SPA fallback to index.html)
  that the runtime image uses, now version-controlled (was only inside the
  published image).
- deploy/Dockerfile.web: packages a prebuilt apps/web/dist into the node:20
  runtime; fails the build if the dist has no Supabase URL baked in.
- deploy/build-aros-web.sh: builds apps/web/dist on the host with
  VITE_SUPABASE_*/SUPABASE_* exported (Vite inlines at build time), verifies
  the URL is present, then packages + optionally pushes the image.

Host-build-then-package is required because the workspace has an absolute
link:/shre-sdk dependency that a hermetic in-container install can't resolve.

Verified: produces an image whose bundle has the Supabase URL, serves /auth
via SPA fallback, /health ok, and does NOT leak the service-role key.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Nirpat3 Nirpat3 changed the title fix(aros-web): bake VITE_SUPABASE_* into build + fail loudly if missing fix(aros-web): reproducible build with Supabase baked in (+ fail-loud guard) Jun 25, 2026
deploy/deploy-aros-web.sh builds the image from source (Supabase baked in)
and recreates the aros container in place — no GitHub Actions, no GHCR push.
Keeps the prior container as a timestamped rollback backup and verifies
/health. Lets aros be shipped entirely from the host while cloud CI is off.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Nirpat3 Nirpat3 merged commit 2b9d490 into main Jun 26, 2026
1 check passed
@Nirpat3 Nirpat3 deleted the fix/aros-web-supabase-build-guard branch June 26, 2026 00:41
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