fix: wire VITE_SENTRY_DSN as Docker build arg so frontend errors reach GlitchTip #645

Closed
opened 2026-05-20 09:53:07 +02:00 by marcel · 0 comments
Owner

Problem

The frontend Sentry SDK is integrated (hooks.client.ts, hooks.server.ts) and reads import.meta.env.VITE_SENTRY_DSN. However, VITE_SENTRY_DSN is a Vite build-time variable — Vite bakes it into the bundle at npm run build. Because the frontend Dockerfile build stage has no ARG VITE_SENTRY_DSN, the variable is undefined at build time and the SDK initialises with enabled: 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:

  1. frontend/Dockerfile — build stage has no ARG VITE_SENTRY_DSN / ENV VITE_SENTRY_DSN
  2. docker-compose.prod.yml — frontend build.args does not include VITE_SENTRY_DSN
  3. .gitea/workflows/nightly.yml — env file writer does not include VITE_SENTRY_DSN secret

Fix

frontend/Dockerfile (build stage)

ARG VITE_SENTRY_DSN
ENV VITE_SENTRY_DSN=$VITE_SENTRY_DSN

Add before RUN npm run build.

docker-compose.prod.yml (frontend service)

build:
  context: ./frontend
  target: production
  args:
    VITE_SENTRY_DSN: ${VITE_SENTRY_DSN:-}

.gitea/workflows/nightly.yml (env file writer)

VITE_SENTRY_DSN=${{ secrets.VITE_SENTRY_DSN }}

Required Action After Merge

Set Gitea repository secret VITE_SENTRY_DSN = https://758169b5be8e4d799d09aaca4215036d@glitchtip.archiv.raddatz.cloud/1

Acceptance Criteria

  • After nightly deploy, frontend JS errors surface in GlitchTip project #1
  • VITE_SENTRY_DSN is absent from the production image layer (build arg, not runtime env)
  • Deploy succeeds when VITE_SENTRY_DSN secret is not yet set (empty fallback :-)
## Problem The frontend Sentry SDK is integrated (`hooks.client.ts`, `hooks.server.ts`) and reads `import.meta.env.VITE_SENTRY_DSN`. However, `VITE_SENTRY_DSN` is a **Vite build-time variable** — Vite bakes it into the bundle at `npm run build`. Because the frontend `Dockerfile` build stage has no `ARG VITE_SENTRY_DSN`, the variable is `undefined` at build time and the SDK initialises with `enabled: 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: 1. `frontend/Dockerfile` — build stage has no `ARG VITE_SENTRY_DSN` / `ENV VITE_SENTRY_DSN` 2. `docker-compose.prod.yml` — frontend `build.args` does not include `VITE_SENTRY_DSN` 3. `.gitea/workflows/nightly.yml` — env file writer does not include `VITE_SENTRY_DSN` secret ## Fix ### `frontend/Dockerfile` (build stage) ```dockerfile ARG VITE_SENTRY_DSN ENV VITE_SENTRY_DSN=$VITE_SENTRY_DSN ``` Add before `RUN npm run build`. ### `docker-compose.prod.yml` (frontend service) ```yaml build: context: ./frontend target: production args: VITE_SENTRY_DSN: ${VITE_SENTRY_DSN:-} ``` ### `.gitea/workflows/nightly.yml` (env file writer) ```yaml VITE_SENTRY_DSN=${{ secrets.VITE_SENTRY_DSN }} ``` ## Required Action After Merge Set Gitea repository secret `VITE_SENTRY_DSN` = `https://758169b5be8e4d799d09aaca4215036d@glitchtip.archiv.raddatz.cloud/1` ## Acceptance Criteria - [ ] After nightly deploy, frontend JS errors surface in GlitchTip project #1 - [ ] `VITE_SENTRY_DSN` is absent from the production image layer (build arg, not runtime env) - [ ] Deploy succeeds when `VITE_SENTRY_DSN` secret is not yet set (empty fallback `:-`)
marcel added the devops label 2026-05-20 09:53:12 +02:00
Sign in to join this conversation.
No Label devops
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: marcel/familienarchiv#645