Check image carries the Go toolchain and module cache; drop them from the final layer #28
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Since #26 the
Dockerfile's bootstrap layer compiles Hugo withgo install,and the Go toolchain plus the module cache stay in the image.
Measured growth,
mainbefore #26 vs after:docker image inspectdocker imagesdocker history, bootstrap layer aloneSo 11x to 27x depending which number you read. The 683 MB figure quoted in
PR #27 is the most flattering of the three and should not be the one that
gets repeated.
Why it is not urgent
The image is only ever built to run
make check—script/cibuildisdocker build .and the result is discarded. It is never published, neverpulled, never deployed. The policy budget is on build time, and that is
fine: 2m26s cold against a five-minute limit.
So this is disk and cache pressure on the build host, not a shipped artifact
problem. Filing it because a 27x jump should be a recorded decision rather than
something discovered later by someone wondering where the disk went — this is a
shared host and other repos' builds compete for the same cache.
Fix
Standard approach is a multi-stage build: compile Hugo in a builder stage, copy
only the resulting binary into the final stage, and leave
GOPATH/GOCACHEbehind.
REPO_POLICIES.mdalready contemplates multistage builds for Go repos.Worth checking first whether it is worth doing at all: if the toolchain layer
caches well and the host has the space, the simpler answer is to leave it and
close this as accepted. Measure before changing.
Definition of done
the same metric before and after, or this is closed as accepted with the
reasoning written down.
hugo versionin the final image still reports the pinnedversion from
script/bootstrap, and the hash-verified install path from #26is preserved — the binary must still come from the verified build, not from
a distro package or an unpinned download.
make checkpasses andscript/cibuildsucceeds with the check layergenuinely executed, not
CACHED(#23).TODO.mdupdated in the same commit.Sequencing
cache-busting fix and this should not land blind of each other. If #23 lands
first, re-verify its two-consecutive-runs proof after this.
script/bootstrap, which runs indeploy.yml'sbuildjob, so thesame rule as #26 applies: if the install path changes, verify on a real
runner via a temporary branch trigger before merging. If only the
Dockerfilechanges andscript/bootstrapis untouched, the deploy path isunaffected and that is not needed — state which case applies.
Out of scope
proxy.golang.orgdependency the deploy path now has.