Skip to content

fix(docker): provide build-time DATABASE_URL + JWT_SECRET for next build - #40

Merged
agustinkassis merged 1 commit into
mainfrom
fix/docker-build-env
Jun 22, 2026
Merged

fix(docker): provide build-time DATABASE_URL + JWT_SECRET for next build#40
agustinkassis merged 1 commit into
mainfrom
fix/docker-build-env

Conversation

@agustinkassis

Copy link
Copy Markdown
Member

Problem

The docker-publish workflow (and docker compose build) failed during next build with Prisma / env-validation errors (Environment variable not found: DATABASE_URL).

lib/prisma.ts instantiates new PrismaClient() at module import (export const prisma = … ?? createClient()), and next build imports every route module — so the builder stage needs DATABASE_URL (a valid Postgres URL; Prisma reads process.env.DATABASE_URL directly) and strict env validation (lib/config/env.ts) needs it too. A JWT_SECRET ≥ 32 chars is required if set.

The CI build job already injects dummy DATABASE_URL + JWT_SECRET — the Dockerfile didn't. Its SKIP_ENV_VALIDATION=1 was a dead no-op (nothing in the codebase reads it), so it never bypassed validation.

Fix

Set placeholder DATABASE_URL + JWT_SECRET in the builder stage only (mirrors CI). They live in the discarded builder stage — they never reach the runtime image, which still takes real values at docker run. The build never connects to the DB.

Verified by dispatching docker-publish from this branch (run) — the multi-arch image builds and pushes masize/lawallet-nwc (amd64 + arm64).

🤖 Generated with Claude Code

`next build` imports route modules that instantiate PrismaClient at import
time (lib/prisma.ts) and run strict env validation (lib/config/env.ts), so the
builder stage needs DATABASE_URL (valid Postgres URL) and a >=32-char
JWT_SECRET, or the build fails with "Environment variable not found:
DATABASE_URL" / env validation errors. This mirrors the dummy values the CI
`build` job already injects.

The previous `SKIP_ENV_VALIDATION=1` was a dead no-op (nothing in the codebase
reads it), so it never bypassed validation. Replace it with placeholder env
that lives only in the discarded builder stage — the runtime image still takes
real values at `docker run`. The build never connects to the DB.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lawallet-api-docs Ready Ready Preview, Comment Jun 22, 2026 3:17am
lawallet-nwc-web Building Building Preview, Comment Jun 22, 2026 3:17am

Request Review

@agustinkassis
agustinkassis merged commit 998ff2b into main Jun 22, 2026
11 of 12 checks passed
@agustinkassis
agustinkassis deleted the fix/docker-build-env branch June 22, 2026 12:47
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