fix: wire VITE_SENTRY_DSN as Docker build arg so frontend errors reach GlitchTip #645
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
The frontend Sentry SDK is integrated (
hooks.client.ts,hooks.server.ts) and readsimport.meta.env.VITE_SENTRY_DSN. However,VITE_SENTRY_DSNis a Vite build-time variable — Vite bakes it into the bundle atnpm run build. Because the frontendDockerfilebuild stage has noARG VITE_SENTRY_DSN, the variable isundefinedat build time and the SDK initialises withenabled: false.Result: no frontend errors ever reach GlitchTip project #1, even though the SDK code is there.
This was discovered while working on #641 (backend Sentry + JSON logging).
Root Cause
Three places all need to be wired together:
frontend/Dockerfile— build stage has noARG VITE_SENTRY_DSN/ENV VITE_SENTRY_DSNdocker-compose.prod.yml— frontendbuild.argsdoes not includeVITE_SENTRY_DSN.gitea/workflows/nightly.yml— env file writer does not includeVITE_SENTRY_DSNsecretFix
frontend/Dockerfile(build stage)Add before
RUN npm run build.docker-compose.prod.yml(frontend service).gitea/workflows/nightly.yml(env file writer)Required Action After Merge
Set Gitea repository secret
VITE_SENTRY_DSN=https://758169b5be8e4d799d09aaca4215036d@glitchtip.archiv.raddatz.cloud/1Acceptance Criteria
VITE_SENTRY_DSNis absent from the production image layer (build arg, not runtime env)VITE_SENTRY_DSNsecret is not yet set (empty fallback:-)