fix(docker): provide build-time DATABASE_URL + JWT_SECRET for next build - #40
Merged
Conversation
`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>
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
docker-publishworkflow (anddocker compose build) failed duringnext buildwith Prisma / env-validation errors (Environment variable not found: DATABASE_URL).lib/prisma.tsinstantiatesnew PrismaClient()at module import (export const prisma = … ?? createClient()), andnext buildimports every route module — so the builder stage needsDATABASE_URL(a valid Postgres URL; Prisma readsprocess.env.DATABASE_URLdirectly) and strict env validation (lib/config/env.ts) needs it too. AJWT_SECRET≥ 32 chars is required if set.The CI
buildjob already injects dummyDATABASE_URL+JWT_SECRET— the Dockerfile didn't. ItsSKIP_ENV_VALIDATION=1was a dead no-op (nothing in the codebase reads it), so it never bypassed validation.Fix
Set placeholder
DATABASE_URL+JWT_SECRETin the builder stage only (mirrors CI). They live in the discarded builder stage — they never reach the runtime image, which still takes real values atdocker run. The build never connects to the DB.Verified by dispatching
docker-publishfrom this branch (run) — the multi-arch image builds and pushesmasize/lawallet-nwc(amd64 + arm64).🤖 Generated with Claude Code