Dockerfile: deps -> builder -> runner. NEXT_PUBLIC_* vars are passed as
build args (inlined into the client bundle at build time, per Next.js);
everything else is read at container runtime instead (docker-compose.yml's
env_file / docker run --env-file) and never baked into an image layer.
Runner stage is non-root, ships only server.js + .next/static + public/
via output: "standalone".
Verified by actually running the build twice locally (Docker itself isn't
available in this environment) -- once with the real .env.local, once with
only placeholder values and no .env.local at all, matching the real Docker
build condition. The second run caught a real, pre-existing bug that had
nothing to do with Docker specifically: /login and three other
client-component trees (location/error, location/permission,
CategoryChips and NeighborhoodSearch nested in Server Component pages) all
call useSearchParams() without a Suspense boundary. next dev tolerates
this; next build hard-fails on it ("missing-suspense-with-csr-bailout").
This would have broken any production build -- Vercel, bare metal,
whatever -- not just Docker; fixed all four by wrapping in <Suspense>.
Also added .env.example (committed, no real values -- .env.local itself
stays gitignored) and a docker-compose.yml, with the --env-file .env.local
requirement called out explicitly in README.md since Compose only
auto-reads a file literally named .env, not .env.local.
17 lines
672 B
YAML
17 lines
672 B
YAML
services:
|
|
web:
|
|
build:
|
|
context: .
|
|
args:
|
|
# Compose substitutes these from its own env (see the --env-file note
|
|
# in README.md's Docker section) — NOT from env_file below, which only
|
|
# affects the running container, not the build.
|
|
NEXT_PUBLIC_GOOYAL_ACCOUNTS_BASE_URL: ${NEXT_PUBLIC_GOOYAL_ACCOUNTS_BASE_URL}
|
|
NEXT_PUBLIC_GOOYAL_CLIENT_ID: ${NEXT_PUBLIC_GOOYAL_CLIENT_ID}
|
|
NEXT_PUBLIC_GOOYAL_CLIENT_SECRET: ${NEXT_PUBLIC_GOOYAL_CLIENT_SECRET}
|
|
NEXT_PUBLIC_GOOYAL_OAUTH_SCOPE: ${NEXT_PUBLIC_GOOYAL_OAUTH_SCOPE}
|
|
env_file:
|
|
- .env.local
|
|
ports:
|
|
- "3000:3000"
|
|
restart: unless-stopped
|