From cdc3e2e4c8843dca505df0edbb19ae91615ee0d1 Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 20 May 2026 09:54:04 +0200 Subject: [PATCH] fix(deploy): wire VITE_SENTRY_DSN as Docker build arg for frontend GlitchTip (#645) VITE_SENTRY_DSN is a Vite build-time variable baked into the JS bundle. Without an ARG/ENV in the Dockerfile build stage and a build.args entry in docker-compose.prod.yml, the SDK initialised with enabled=false regardless of the Gitea secret value. - frontend/Dockerfile: add ARG VITE_SENTRY_DSN + ENV before npm run build - docker-compose.prod.yml: add build.args.VITE_SENTRY_DSN with empty fallback - nightly.yml: write VITE_SENTRY_DSN secret into .env.staging Requires Gitea secret VITE_SENTRY_DSN to be set to the GlitchTip project #1 DSN. Co-Authored-By: Claude Sonnet 4.6 --- .gitea/workflows/nightly.yml | 1 + docker-compose.prod.yml | 4 ++++ frontend/Dockerfile | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/.gitea/workflows/nightly.yml b/.gitea/workflows/nightly.yml index 14a962ed..152050bb 100644 --- a/.gitea/workflows/nightly.yml +++ b/.gitea/workflows/nightly.yml @@ -79,6 +79,7 @@ jobs: IMPORT_HOST_DIR=/srv/familienarchiv-staging/import POSTGRES_USER=archiv SENTRY_DSN=${{ secrets.SENTRY_DSN }} + VITE_SENTRY_DSN=${{ secrets.VITE_SENTRY_DSN }} EOF - name: Verify backend /import:ro mount is wired diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 46504417..fe435306 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -268,6 +268,10 @@ services: build: context: ./frontend target: production + args: + # Vite build-time variable — baked into the JS bundle at build time. + # Empty default so deploys succeed before the secret is configured. + VITE_SENTRY_DSN: ${VITE_SENTRY_DSN:-} restart: unless-stopped depends_on: backend: diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 344d5cb6..6347e64d 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -16,6 +16,10 @@ CMD ["npm", "run", "dev"] # Compiles the SvelteKit Node-adapter output to /app/build. FROM node:20.19.0-alpine3.21 AS build WORKDIR /app +# VITE_SENTRY_DSN is a build-time variable — Vite bakes it into the bundle. +# Passed via docker-compose build.args; empty string disables the SDK. +ARG VITE_SENTRY_DSN +ENV VITE_SENTRY_DSN=$VITE_SENTRY_DSN COPY package.json package-lock.json ./ RUN npm ci COPY . .