Skip to content

Fix runtime crash: keep the node_modules tree bun install produced - #3

Merged
ralyodio merged 1 commit into
mainfrom
fix/docker-runtime-modules
Aug 11, 2026
Merged

ralyodio merged 1 commit into
mainfrom
fix/docker-runtime-modules

Conversation

@ralyodio

Copy link
Copy Markdown
Contributor

The api and worker images built cleanly and then crashed on boot in production:

error: Cannot find module "@libsql/client" from "/app/packages/db/src/client.ts"

Cause

Bun does not hoist every workspace dependency to the root node_modules — some land in the package own node_modules. The runtime stage copied only /app/node_modules and then re-copied packages/ from the build context, deleting those per-package trees.

Both runtime stages now extend deps, which keeps the exact tree bun install produced. Dev dependencies ship in the image as a result; correctness is worth more than the size, and this can be tightened later with a pruned install once there is a smoke test guarding it.

This is the same root cause as the earlier next: command not found in the web image, which was fixed the same way. It should have prompted a check of the other two Dockerfiles at the time, and did not.

Why it reached production

The docker CI job only ever proved that an image builds. Nothing ever started a container.

This PR adds a smoke job that boots the api and worker images and waits for /health/live, failing fast if the container exits early rather than waiting out the timeout. Both would have failed on the previous commit.

Verification

CI now covers: format, typecheck, 265 tests, migrations against an empty database, PWA build, three image builds, and two container boots.

🤖 Generated with Claude Code

The api and worker images built cleanly and then crashed on boot:

  error: Cannot find module '@libsql/client' from '/app/packages/db/src/client.ts'

Bun does not hoist every workspace dependency to the root node_modules —
some land in the package's own node_modules. The runtime stage copied only
/app/node_modules and then re-copied packages/ from the build context,
deleting those per-package trees. Both runtime stages now extend deps, which
keeps the exact tree bun install produced. Dev dependencies ship in the
image as a result; correctness is worth more than the size.

Adds a smoke job to CI. The docker job only ever proved an image builds,
which is why this reached production — the new job boots the container and
waits for /health/live, failing fast on a crashloop.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@ralyodio
ralyodio merged commit 12cb643 into main Aug 11, 2026
8 checks passed
@ralyodio
ralyodio deleted the fix/docker-runtime-modules branch August 11, 2026 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant