docs(docker): tsx in a --prod image must be a regular dependency - #68
Merged
Conversation
The page printed `CMD ["npx", "tsx", "src/index.ts"]` and mentioned adding tsx as a dependency in passing. A production image installs with `--omit=dev`, so a tsx left in devDependencies is simply not there, and `npx` then downloads it from the registry at container start. Verified in a container: with tsx in devDependencies and `--network none` the image fails to start with `request to https://registry.npmjs.org/tsx failed`; moving tsx to dependencies makes the same image start normally. With network the failure is worse than a crash — every start silently fetches a package. `connectum init --node-exec tsx` puts tsx in devDependencies, which is right for running from source and wrong for a --prod image, so the callout says to move it or to pin the run command to the resolved binary, which fails at build time instead of at start-up.
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.
The defect
The page printed this and mentioned adding tsx as a dependency in passing:
A production image installs with
--omit=dev(or--prod), so a tsx left indevDependenciesis not in the image.npxthen downloads it from the registry when the container starts.Verified in a container:
--network nonedevDependenciesrequest to https://registry.npmjs.org/tsx faileddependenciesWith network the outcome is arguably worse than a crash: every container start silently fetches a package from the registry.
This matters beyond the docs page, because
connectum init --node-exec tsxputs tsx indevDependencies— correct for a project that runs from source, wrong for a--prodimage.The fix
A
dangercallout with the measured evidence, the reason, and two ways out: move tsx todependencies, or pin the run command to the resolved binary (CMD ["./node_modules/.bin/tsx", "src/index.ts"]) so a missing dependency fails at build time rather than at start-up.Found while closing out the container-e2e work — the tsx execution model was listed as "not covered", and checking why turned up a documented path that does not work.