Dockerfile: recursive chown /actions-runner after tarball extract#585
Conversation
Harden the invariant that entrypoint.sh #583 now relies on: every file under /actions-runner is runner-owned in the image. Previously this was true only because GitHub's actions-runner release tarball happens to encode UIDs that coincide with this image's runner user (UID 1001). The non-recursive chown in this RUN step only touched the three top-level directories; ownership of the ~9 000 files extracted from the tarball was inherited verbatim from the archive metadata. Making the chown recursive establishes the invariant in this repo instead of inheriting it by coincidence: - entrypoint.sh #583 skips chown -R over bin/ and externals/ on every container start; that optimisation now has a locally-enforced precondition rather than one that depends on upstream tarball packaging conventions. - Derived images (FROM myoung34/github-runner:...) no longer depend on the tarball's happen-to-be-runner-owned ownership either. - Forks that rebuild the base image with a different runner UID get correct ownership without having to remember to re-chown. Cost is paid once at image build time, inside the same RUN that extracts the tarball, so it does not add a new layer or inflate image size beyond the chown metadata in the existing layer.
|
Less ai in the future please |
|
I referred to that follow up in my previouse contribution, the code is minimal, defensive and reasonable. thank You so much to merge my previouse PR - atm I swap out that line via SED before starting my containers ... that bug stalled i/o on one of my proxmox servers big time... greetings from Vienna (if You ever come here, lets compare our beers) |
|
Sorry I meant just in the description etc, it's very obtuse and conflated but the pr is fine |
What
Change the build-time ownership fix-up from
to
i.e. make it recursive.
/_workand/opt/hostedtoolcacheare empty at this point so-Ris a no-op for them; the meaningful change is that every file extracted from the actions-runner release tarball is now explicitlyrunner-owned in the resulting image layer.Why - the invariant that #583 relies on
#583 stopped walking
/actions-runner/bin(~50 MB) and/actions-runner/externals(~330 MB, ~9 000 files) on every container start, on the grounds that they are alreadyrunner:runnerin the image. That observation is correct today, but why is it correct? Tracing it:Dockerfilechown runner /_work /actions-runner /opt/hostedtoolcachewas non-recursive - it only flipped the three top-level directory inodes.install_actions.shextracts the tarball withtar -zxf, which (running as root) preserves the UIDs/GIDs stored inside the archive.runneruser (UID 1001 in the base image). That's a coincidence of how GitHub publishes the release tarball, not something this repo establishes.So
entrypoint.sh's optimisation is load-bearing on upstream tarball packaging conventions. If GitHub ever re-rolls the tarball with different UIDs, or if a downstream fork rebuilds the base image with a differentrunnerUID, ownership underbin/andexternals/would silently drift and the entrypoint would no longer fix it.Making the chown recursive here establishes the invariant in this repo:
FROM myoung34/github-runner:...) inherit correctly-owned files regardless of tarball UID layout.runnerUID get correct ownership automatically, without having to remember to add their ownchown -R.Cost
Paid once at image build time, inside the same
RUNthat extracts the tarball - so no new layer, and the chown metadata lands in a layer that is already being written. No measurable impact on image size; ~9 000 extrachownsyscalls during build, which is noise compared to the tarball download and dependency install in the same step.No runtime cost - this is the opposite of the runtime cost that #583 removed.
Scope
chown→chown -R) on the Dockerfile's existing fix-up line.install_actions.sh,entrypoint.sh, the base image,_work/opt/hostedtoolcachehandling.Relation to prior work
Direct follow-up to #583 ("entrypoint: skip recursive chown over /actions-runner/{bin,externals}") - I flagged this hardening as an open question in that PR's description. Same spirit as #268 (narrowing the
/opt/hostedtoolcachechown) in that both favour doing ownership work at the right point in the image lifecycle rather than repeating it on every container start.