fix(docker): unblock task 16 build (prisma dir + env validation) #1

Merged
janpeter merged 1 commit from fix/prisma-dir-bootstrap into main 2026-05-26 20:39:01 +02:00
Owner

Summary

Twee build-blockers gerapporteerd door server-Claude tijdens M16 fase 1 task 16 (docker compose build scrum4me-workers).

Fix 1 — prisma/ dir bestaat niet in build context (commit 68486d8)

RUN bash scripts/gen-schema.sh > prisma/schema.prisma
→ cannot create prisma/schema.prisma: Directory nonexistent
  • prisma/schema.prisma en prisma/migrations/ zijn gitignored
  • Empty dir is niet getrackt door git → git clone levert geen prisma/ dir op
  • Bash shell-redirect opent het output-bestand vóór de gen-schema script runt

Fix: Dockerfile prefix mkdir -p prisma && + commit prisma/.gitkeep voor lokale dev-reproducibiliteit.

Fix 2 — lib/env.ts throwt tijdens next build static analysis (commit 007d896)

next build importeert modules om route-metadata te verzamelen. lib/env.ts doet safeParse(process.env) op module-load en throwt als DATABASE_URL/WORKERS_SESSION_SECRET missen — wat tijdens build het geval is (env_file landt pas at-runtime).

Fix: SKIP-gate in lib/env.ts:

const SKIP_VALIDATION =
  process.env.SKIP_ENV_VALIDATION === '1' ||
  process.env.NEXT_PHASE === 'phase-production-build'

if (!SKIP_VALIDATION && !parsed.success) { throw ... }
export const env: Env = parsed.success ? parsed.data : ({} as Env)

Plus ENV SKIP_ENV_VALIDATION=1 in Dockerfile builder-stage vóór RUN npm run build.

Runtime (dev/start/test) blijft volledig valideren — alleen next build static-analysis krijgt de bypass.

Test plan

Lokaal getest:

  • SKIP_ENV_VALIDATION=1 tsx import lib/env.ts → env={} no throw
  • Met DATABASE_URL+WORKERS_SESSION_SECRET set → env gevalideerd + populated
  • npm run verify → 15/15 tests passing, typecheck clean, lint clean (0 errors, 0 warnings)

Server-Claude retry na merge:

cd /srv/scrum4me/repos/scrum4me-workers && git pull --ff-only
cd /srv/scrum4me/compose && docker compose build scrum4me-workers

Verwacht: build slaagt door alle RUN-lines (gen-schema, prisma generate, npm run build met SKIP).

Context

Blocker voor M16 fase 1 task 16. Server-werk staat al klaar (/srv/scrum4me/secrets/workers.env + compose-edit + ops-flow met git_submodule_update-step) — alleen build wacht.

## Summary Twee build-blockers gerapporteerd door server-Claude tijdens M16 fase 1 task 16 (`docker compose build scrum4me-workers`). ## Fix 1 — `prisma/` dir bestaat niet in build context (commit `68486d8`) ``` RUN bash scripts/gen-schema.sh > prisma/schema.prisma → cannot create prisma/schema.prisma: Directory nonexistent ``` - `prisma/schema.prisma` en `prisma/migrations/` zijn gitignored - Empty dir is niet getrackt door git → `git clone` levert geen `prisma/` dir op - Bash shell-redirect opent het output-bestand vóór de gen-schema script runt **Fix:** Dockerfile prefix `mkdir -p prisma &&` + commit `prisma/.gitkeep` voor lokale dev-reproducibiliteit. ## Fix 2 — `lib/env.ts` throwt tijdens `next build` static analysis (commit `007d896`) `next build` importeert modules om route-metadata te verzamelen. `lib/env.ts` doet `safeParse(process.env)` op module-load en throwt als `DATABASE_URL`/`WORKERS_SESSION_SECRET` missen — wat tijdens build het geval is (env_file landt pas at-runtime). **Fix:** SKIP-gate in `lib/env.ts`: ```ts const SKIP_VALIDATION = process.env.SKIP_ENV_VALIDATION === '1' || process.env.NEXT_PHASE === 'phase-production-build' if (!SKIP_VALIDATION && !parsed.success) { throw ... } export const env: Env = parsed.success ? parsed.data : ({} as Env) ``` Plus `ENV SKIP_ENV_VALIDATION=1` in Dockerfile builder-stage vóór `RUN npm run build`. Runtime (dev/start/test) blijft volledig valideren — alleen `next build` static-analysis krijgt de bypass. ## Test plan Lokaal getest: - [x] `SKIP_ENV_VALIDATION=1 tsx import lib/env.ts` → env={} no throw - [x] Met `DATABASE_URL`+`WORKERS_SESSION_SECRET` set → env gevalideerd + populated - [x] `npm run verify` → 15/15 tests passing, typecheck clean, lint clean (0 errors, 0 warnings) Server-Claude retry na merge: ```bash cd /srv/scrum4me/repos/scrum4me-workers && git pull --ff-only cd /srv/scrum4me/compose && docker compose build scrum4me-workers ``` Verwacht: build slaagt door alle RUN-lines (gen-schema, prisma generate, npm run build met SKIP). ## Context Blocker voor [M16 fase 1 task 16](https://git.jp-visser.nl/janpeter/Scrum4Me/src/branch/main/docs/plans/M16-platform-split-fase-1-workers-scaffold.md#task-16-server-clone-scrum4me-workers--docker-compose-service--build--up). Server-werk staat al klaar (`/srv/scrum4me/secrets/workers.env` + compose-edit + ops-flow met `git_submodule_update`-step) — alleen build wacht.
`prisma/schema.prisma` and `prisma/migrations/` are gitignored, so the
`prisma/` directory itself is not tracked by git. Empty dirs aren't tracked
either, which means Docker's COPY-from-context doesn't bring `prisma/` into
the build image.

Dockerfile line 28 `RUN bash scripts/gen-schema.sh > prisma/schema.prisma`
fails with "cannot create prisma/schema.prisma: Directory nonexistent"
because bash's redirect tries to open the file before gen-schema.sh runs
(the script's own `mkdir -p` inside doesn't help — that runs after the
shell redirect is set up).

Two fixes:
1. Dockerfile: prepend `mkdir -p prisma &&` to the gen-schema RUN line.
2. Commit `prisma/.gitkeep` so the directory exists after `git clone`
   (defense-in-depth for local dev + future COPY-based Dockerfiles).

Tested locally: dir exists in fresh clone, schema generation works.

Reported by server-Claude during task 16 docker build of fase 1.
janpeter changed title from fix(docker): create prisma/ dir before generating schema to fix(docker): unblock task 16 build (prisma dir + env validation) 2026-05-26 20:48:17 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
janpeter/scrum4me-workers!1
No description provided.