Docker image build fails: prerendering /c/[...slug] needs a database #121

Closed
opened 2026-11-05 18:25:21 +01:00 by miko · 1 comment
Owner

docker build . fails on a clean checkout of development (seen at 6146cf9), in the build stage's npm run build:

Error occurred prerendering page "/c/[...slug]". Read more: https://nextjs.org/docs/messages/prerender-error
Error: error parsing connection string, format must be 'mariadb://[<user>[:<password>]@]<host>[:<port>]/[<db>…]'
    at async m (src/categories/loadCategoryTree.ts:16:3)
Export encountered an error on /c/[...slug]/page: /c/[...slug], exiting the build.

During the build, Next prerenders /c/[...slug] and with it the cached category tree (readCategoryNodes). The image build has no DATABASE_URL, so src/db.ts gets an empty connection string and the build fails. Local builds and the e2e build have a database, which is why they pass.

Version 1.1.1 still built, so this came in with a later change to the category pages or the category tree cache. A release cannot be built until this is fixed (ADR-0014).

Found while working on #109: the restore command could not be checked inside a built image because of this.

To reproduce: git worktree add /tmp/k development && cd /tmp/k && docker build --target build .

`docker build .` fails on a clean checkout of `development` (seen at 6146cf9), in the build stage's `npm run build`: ``` Error occurred prerendering page "/c/[...slug]". Read more: https://nextjs.org/docs/messages/prerender-error Error: error parsing connection string, format must be 'mariadb://[<user>[:<password>]@]<host>[:<port>]/[<db>…]' at async m (src/categories/loadCategoryTree.ts:16:3) Export encountered an error on /c/[...slug]/page: /c/[...slug], exiting the build. ``` During the build, Next prerenders `/c/[...slug]` and with it the cached category tree (`readCategoryNodes`). The image build has no `DATABASE_URL`, so `src/db.ts` gets an empty connection string and the build fails. Local builds and the e2e build have a database, which is why they pass. Version 1.1.1 still built, so this came in with a later change to the category pages or the category tree cache. A release cannot be built until this is fixed (ADR-0014). Found while working on #109: the restore command could not be checked inside a built image because of this. To reproduce: `git worktree add /tmp/k development && cd /tmp/k && docker build --target build .`
Author
Owner

Duplicate of #134, fixed in 14a0fe3 (generateMetadata awaits params before loading the category tree). docker build --target build on development at 6d295de passes again. A check that catches this before a release follows in a new ticket.

Duplicate of #134, fixed in 14a0fe3 (generateMetadata awaits params before loading the category tree). `docker build --target build` on development at 6d295de passes again. A check that catches this before a release follows in a new ticket.
miko closed this issue 2026-11-06 14:48:30 +01:00
Sign in to join this conversation.
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
MassiveDynamic/kataba#121
No description provided.