Repository navigation
Conversation
`chgrp -R 0 /app && chmod -R g=u /app` ran as a final layer, after python packages, the uv binary, the python plugins and the server binary had already been written by earlier layers. Overlayfs has to copy every file it mutates into the new layer, so the image shipped a second full copy of /app: measured at 186.5 MB of a 516.6 MB image. Apply the ownership where the files are created instead: - add devlake to group 0 so it may chgrp the files it owns; its primary group stays devlake, so the runtime GID is unchanged - fold the pip and uv installs into one RUN and normalise /app/.local at the end of it - normalise /app/python at the end of the plugin build - create logs with group 0 up front Everything copied into the final stage is read-only at runtime, so `--chown=0:0` is enough; the modes it already has (755 binary, 644 docs) let any GID 0 process read and execute it. Verified with a replica image that the ownership and modes are byte-identical to the old pattern (devlake:root 775/664) while the duplicate layer disappears. Expected result: ~330 MB instead of 516.6 MB.
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.
Summary
chgrp -R 0 /app && chmod -R g=u /appruns as a final layer indevlake-base, after python packages, the uv binary, the python plugins and the server binary have already been written by earlier layers. Overlayfs has to copy every file it mutates into the new layer, so the published image carries a second full copy of/app: 186.5 MB of the 516.6 MB total, measured onapache/devlake:v1.0.3-beta19.This applies the ownership where the files are created instead, so no second copy is written.
useradd … -G 0chgrpits own files to group 0; the primary group staysdevlake, so the runtime GID does not changeRUN, ending withchgrp/chmod /app/.local/app/.local; normalising it in a later layer would copy it up again… build.sh && chgrp -R 0 /app/python && chmod -R g=u /app/pythonmkdir logs && chgrp 0 logs && chmod g=u logs/app/logsis the only writable path the app needs at startupCOPY --chown=0:0forlakeandresourcesmkdir -p -m 0775 /app/bin/pluginsResulting ownership and modes are identical to the old recursive pass (
devlake:root, 775 directories / 664 files), which is what the OpenShift arbitrary-UID support added in #8657 relies on.Verification
I could not build the full image locally: this machine has no
buildx, and the legacy builder rejectsFROM --platform=$BUILDPLATFORMin the earlier stage before it reaches these. So:1. Mechanism, with a replica image. Same instructions, 40 MB of payload: the old ordering produces a 41.9 MB content layer plus a 42.0 MB duplicate; the new ordering produces a single 42.0 MB layer. Ownership and modes are identical (
devlake:root 775/664).2. The real
basestage, built from a trimmed copy of the Dockerfile (--target base, builder stage removed):3. The arbitrary-UID contract still holds. Running as
-u 1000120000:0(what OpenShift does):idinside the image reportsgid=1010(devlake) groups=1010(devlake),0(root)— the primary GID is unchanged; group 0 is supplementary, which is what lets the userchgrp.Expected size: the published beta19 image spends 186.5 MB of its 516.6 MB on that one layer. Folding the chgrp into the layers that create the files removes it, so the image should land around 330 MB. That number is arithmetic from the published manifest, not a local measurement — the final stage can only be built by CI.
Does this close any open issues?
Refs #9276.
Other Information
config-ui/Dockerfilehas the same latechgrp -Rpattern over nginx and/run. It is worth the same treatment, but those trees are far smaller and messing with nginx permissions deserves its own PR.