Added --chmod to all COPY instructions in Dockerfile #1184
Merged
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.
This removes any file-permission ambiguity that can result from a different umask set at git checkout
time on developer's or build machine.
This problem was noticed when running a
buildxon MacOS with aumaskset of0077. Git doesn't do anything special withrwattributes, onlyx, so these are inherited from the checkout user'sumask. Since Docker passes these through, this seems to be a flaw in build-portability of Git Checkout -> Docker Build (same build args) -> Image. So my image fails to run asminecraft:minecraftdue mainly to missing group/worldrpermissions ...xthat is added currently is not sufficient and will fail immediately with:This PR adds
--chmodto allCOPYinstructions in theDockerfile, to force consistency. Note thatCOPY --chmodis buildkit and not plain Docker, but that is already required.Testing
This command (apologies for the quoting) attempts to
lsall the files copied-in to the image, and compare the permissions from the current image with one from a local build.Note the first diff input is from
itzg/minecraft-server, the second is local tagminecraft-server.For a "bad" build with
umask 0077, there will be a lot of diffs, and the bad side looks like this:Note the odd 711 perms.
Built with this PR, there are no diffs between official and locally-built image.
Downside - need to remember to add
--chmodto any futureCOPYcommands.