1
0
Fork 0
fahrPool/web
Jonny 2f508ea5dd feat: containerize the Next.js app and wire it into docker-compose
Adds web/Dockerfile (multi-stage node:22-alpine build, standalone output)
and web/.dockerignore, and wires a `web` service into docker-compose.yaml
so the whole stack (self-hosted Supabase + Next.js) starts with a single
`docker compose up -d`.

Networking fix: Next.js inlines NEXT_PUBLIC_* env vars at build time into
every compiled bundle, including server-side ones (Server Actions, Server
Components, Middleware) - not just the browser bundle. Since
NEXT_PUBLIC_SUPABASE_URL must point at the externally-reachable
http://localhost:8000 for the browser, the server-side Supabase clients in
lib/supabase/server.ts and lib/supabase/middleware.ts got that same literal
baked in - which resolves to the web container itself (not kong) once
running in Docker, causing ECONNREFUSED on any server-side Supabase call
(most visibly signInWithPassword in the login server action).

Fix: introduce SUPABASE_INTERNAL_URL, a server-only env var without the
NEXT_PUBLIC_ prefix, so it's read at actual runtime rather than inlined at
build time. It points at http://kong:8000 in docker-compose.yaml (same
pattern already used by the studio service's internal SUPABASE_URL) and at
http://localhost:8000 in web/.env.local(.example) for non-Docker local dev,
where there's no container networking boundary. lib/supabase/client.ts
(browser-only) is untouched and keeps reading NEXT_PUBLIC_SUPABASE_URL.

Considered extra_hosts: ["localhost:host-gateway"] instead, but rejected it:
overriding what the literal string "localhost" resolves to inside a
container is unreliable (glibc's resolver typically still prioritizes the
container's own loopback), and is the kind of workaround that looks fixed
in a quick check and quietly breaks later.

Verified end-to-end against the running container via curl (unauth redirect,
real signInWithPassword through the login server action, authenticated
dashboard content, logout) with zero ECONNREFUSED in `docker compose logs
web` afterward, plus a local `npm run dev` smoke test to confirm non-Docker
development still works unchanged.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-05 00:25:01 +02:00
..
app feat: add root layout, role-based navigation and dashboard 2026-07-04 16:14:53 +02:00
components feat: add root layout, role-based navigation and dashboard 2026-07-04 16:14:53 +02:00
lib feat: containerize the Next.js app and wire it into docker-compose 2026-07-05 00:25:01 +02:00
public chore: scaffold Next.js app with Vitest 2026-07-04 10:58:26 +02:00
.dockerignore feat: containerize the Next.js app and wire it into docker-compose 2026-07-05 00:25:01 +02:00
.env.local.example feat: containerize the Next.js app and wire it into docker-compose 2026-07-05 00:25:01 +02:00
.gitignore feat: add Supabase browser and server client helpers 2026-07-04 15:32:05 +02:00
Dockerfile feat: containerize the Next.js app and wire it into docker-compose 2026-07-05 00:25:01 +02:00
README.md chore: scaffold Next.js app with Vitest 2026-07-04 10:58:26 +02:00
eslint.config.mjs chore: scaffold Next.js app with Vitest 2026-07-04 10:58:26 +02:00
middleware.ts feat: add auth middleware with session refresh and redirects 2026-07-04 15:57:41 +02:00
next.config.ts chore: scaffold Next.js app with Vitest 2026-07-04 10:58:26 +02:00
package-lock.json feat: add Supabase browser and server client helpers 2026-07-04 15:32:05 +02:00
package.json feat: add Supabase browser and server client helpers 2026-07-04 15:32:05 +02:00
tsconfig.json chore: scaffold Next.js app with Vitest 2026-07-04 10:58:26 +02:00
vitest.config.ts chore: scaffold Next.js app with Vitest 2026-07-04 10:58:26 +02:00

README.md

This is a Next.js project bootstrapped with create-next-app.

Getting Started

First, run the development server:

npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev

Open http://localhost:3000 with your browser to see the result.

You can start editing the page by modifying app/page.tsx. The page auto-updates as you edit the file.

This project uses next/font to automatically optimize and load Geist, a new font family for Vercel.

Learn More

To learn more about Next.js, take a look at the following resources:

You can check out the Next.js GitHub repository - your feedback and contributions are welcome!

Deploy on Vercel

The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.

Check out our Next.js deployment documentation for more details.