fix: stop shipping a second copy of the toolchain in every Railpack image - #4
Open
jeroenrinzema wants to merge 2 commits into
Open
fix: stop shipping a second copy of the toolchain in every Railpack image#4jeroenrinzema wants to merge 2 commits into
jeroenrinzema wants to merge 2 commits into
Conversation
…mage
The non-root layer ended with `chown -R 1000:1000 /mise`. /mise arrives from
an earlier layer, so rewriting its ownership makes BuildKit record every file
in it again: a byte-identical duplicate of the whole toolchain, in the layer
users pull. On a stock create-next-app that is 194 MB on disk and 58.7 MB
across the wire, for no change in content.
It was never needed. /mise/installs is drwxr-xr-x root:root, so uid 1000
already has the read and execute it uses. What mise does want at runtime is
somewhere to write, and it takes exactly two directories -- without them it
prints `migrate: failed create_dir_all: /mise/migrations` on every start.
Create those two instead of taking ownership of the tree.
Measured on linux/arm64 against Railpack v0.35.0, uncompressed image size:
create-next-app 1163 MB -> 969 MB
Flask + gunicorn 407 MB -> 328 MB
Both run as uid=1000(railpack) and serve 200. Verified node, npm, python and
pip resolve through /mise/shims, that `mise exec` and `mise ls` work, and that
no permission warning is left on either.
Leaves only the warning that has to survive: chowning /mise duplicates the toolchain, which is the mistake this fix exists to prevent being reintroduced.
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.
Every Railpack image we build ships a byte-identical second copy of the toolchain. A stock
create-next-appis 1163 MB on disk; 194 MB of that is the duplicate.Cause
The non-root layer ended with:
/misearrives from an earlier layer.chownrewrites every file it touches, so BuildKit records the entire tree again in the layer users pull — same bytes, different owner. It is the single largest layer we add and it contributes nothing.Why the chown was unnecessary
/mise/installsis alreadydrwxr-xr-x root:root, so uid 1000 has the read and execute it actually uses.What mise does need is somewhere to write. Drop the chown outright and it prints
[WARN] migrate: failed create_dir_all: /mise/migrationson every start — non-fatal, but it lands in the user's logs. It wants exactly two directories, andMISE_CACHE_DIR=/mise/cacheis in the runtime env while that directory does not exist at all. Creating both empty costs nothing measurable and leaves no warning.Verification
Built through the same path the CLI drives (Railpack v0.35.0,
linux/arm64, same frontend and plan), on two stacks so this is not a Node-only claim:create-next-app(Next 16.3.0)For each, as
uid=1000(railpack):/_next/static/…css)node/npmandpython/pipresolve through/mise/shimsmise exec -- …andmise lssucceedcreate_dir_allwarning remainsThe
layout.runtime_user == 1000:1000assertion inbuild()still holds —USER 1000:1000is unchanged, so the guard against a root image is untouched.Not addressed here
cp -a /root/. /home/railpack/leaves two copies of whatever Railpack puts in/root(it includes/root/.cachein the deploy step). That was ~7 MB on both stacks, and unlike the chown the copy is doing real work — the runtime user'sHOMEmoves — so it needs a different fix than deleting a line.Separately: Railpack v0.35.0 ignores Next.js
output: 'standalone'— the generated deploy plan is byte-identical with and without it, and/app/node_modulesships unconditionally. Shrinking that is arailpack.jsonmatter for the app, not a CLI change.