fix(docker): the images could build green and ship without an entrypoint - #419
Merged
Conversation
Found by deploying the Core to kind: the container met CrashLoopBackOff
with `Cannot find module '/repo/src/apps/core-api/dist/main'` from an
image whose build had exited 0.
The repository had NO `.dockerignore`. All three service Dockerfiles do
`COPY src ./src` and then build inside the image with `npx tsc -b`, which
is a COMPOSITE build: it reads `.tsbuildinfo` to decide what still needs
emitting. The working tree's `.tsbuildinfo` files rode into the context,
`tsc -b` concluded the output was already current, and emitted nothing.
The image carried a `dist/` with most of its files and no `main.js`.
CI never saw it, and could not: CI builds from a fresh checkout, which has
no `.tsbuildinfo`. The inverse of the usual failure — green in CI, broken
on every developer machine that had built before.
Two changes, because the first alone would only close the trigger anyone
happens to know about:
- `.dockerignore` excludes `**/*.tsbuildinfo` (the cause) and `**/dist`,
`**/node_modules` and the usual noise. Every runner stage copies
`--from=builder`, so a host `dist` was never the shipped artifact —
letting it into the context only risked a stale build passing as fresh.
- each Dockerfile asserts its own entrypoint after building, so an image
without one fails the BUILD rather than a cluster.
Verified by measurement, and the assertion was WATCHED failing rather than
assumed able to:
- with 11 `.tsbuildinfo` present in the tree, all three images now build
and each carries its `dist/main.js`;
- pointed at a path that does not exist, the assertion turns the build
red and prints its diagnosis;
- with the `**/*.tsbuildinfo` line commented out, the build fails too —
at `tsc -b` (exit 2) rather than at the assertion, because `**/dist`
is excluded as well, so the silent no-op becomes a loud error. Both
doors are shut; only one of them was the original.
Guards: governance suite 17/17, 56-validate-docker-workspace-closure OK
(4 images, 663 sources), gitleaks clean.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
📊 Bilingual Coverage ImpactPR Changes
Repository Coverage
✅ Good: All EN changes have ES counterparts. Generated by GitHub Actions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found by deploying the Core to kind: the container met
CrashLoopBackOffwithfrom an image whose build had exited 0.
Cause
The repository had no
.dockerignore. All three service Dockerfiles doCOPY src ./srcand then build inside the image withnpx tsc -b— a composite build, which reads.tsbuildinfoto decide what still needs emitting. The working tree's.tsbuildinfofiles rode into the build context,tsc -bconcluded the output was already current, and emitted nothing. The image carried adist/with most of its files and nomain.js.CI never saw it and could not: CI builds from a fresh checkout, which has no
.tsbuildinfo. The inverse of the usual failure — green in CI, broken on every developer machine that had built before.Fix
Two changes, because the first alone would only close the trigger someone happened to know about.
.dockerignoreexcludes**/*.tsbuildinfo(the cause), plus**/dist,**/node_modulesand the usual noise. Every runner stage copies--from=builder, so a hostdistwas never the shipped artifact — letting it into the context only risked a stale build passing as fresh.Verification — the assertion was watched failing, not assumed able to
.tsbuildinfopresent in the treedist/main.js**/*.tsbuildinfoline commented outtsc -b(exit 2), not the assertion, because**/distis excluded too, so the silent no-op becomes a loud errorBoth doors are shut; only one of them was the original.
ci-runner.mjs governance56-validate-docker-workspace-closuregitleaks dir .🤖 Generated with Claude Code