agentsclimarketplace

Docker find chmod fast readability

Skill kjuhwa/skills-hub/skills/build/docker-find-chmod-fast-readability

In a Dockerfile RUN layer, use find -not -perm to touch ONLY files missing a permission bit instead of chmod -R — cuts image build time from minutes to seconds on big node_modules trees.From its SKILL.md

Install
npx -y skills add kjuhwa/skills-hub --skill docker-find-chmod-fast-readability

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

2.3 KB, 486 tokens by cl100k_base, as published. Nobody here has run it

chmod smart in Docker (find -not -perm)

When to use

  • You want world-readable app files inside a container so docker run --user $(id -u):$(id -g) works for arbitrary host users.
  • Your /app has hundreds of thousands of files (node_modules - looking at you).
  • chmod -R o+r /app takes minutes and explodes the layer size.

How it works

chmod -R walks every inode and writes the new mode unconditionally. find -not -perm only invokes chmod on files that actually need it:

RUN find /app -not -perm -o=r -exec chmod o+r {} + && \
    find /app -type d -not -perm -o=x -exec chmod o+x {} +
  • -o=r / -o=x = "other has read/execute". -not -perm -o=r = "other is missing read".
  • -exec chmod o+r {} + = batch up arguments (like xargs), one chmod per batch instead of per file.
  • Directory pass is separate because you want o+x (traversability) not o+r on dirs if you're being precise.

Example

Slow:

RUN chmod -R o+r /app  # ~3 minutes on 300k files

Fast:

RUN find /app -not -perm -o=r -exec chmod o+r {} + && \
    find /app -type d -not -perm -o=x -exec chmod o+x {} +
# ~15 seconds, and the layer is tiny because most files didn't actually change

Gotchas

  • Layer size: chmod -R rewrites every file even if mode didn't change, bloating the diff layer. The find approach writes only deltas.
  • Don't forget BOTH passes - if you only o+r, dirs without o+x make files unreachable.
  • -exec {} + > -exec {} \; by 10-100x because it batches.
  • Symlinks: by default chmod follows, find doesn't; add -L if symlink targets matter.
  • This trick is especially valuable for images that wrap Node/Bun monorepos.

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.