Repository navigation
docker: stamp the version into the image, and assert it on every build - #562
Merged
Merged
Conversation
`orlyc --help` in the published image reported "Build: unknown", including in
the v0.1.0-rc1 release candidate. `make version` derives the string from
`git describe`, .dockerignore excludes .git, so inside the image build there
was never anything to describe.
That was a documented trade ("fine for an image whose tag carries the
version") and it held while the image was only ever :latest. It stops holding
at a release: someone running :latest -- which is what the README tells them
to run -- has no way to ask the binary what it is.
So pass the version in. New ORLY_VERSION build arg writes orly/build_version.h
directly when set and falls back to `make version` when it is not, so a bare
`docker build .` behaves exactly as before. The workflow resolves it to the
tag on a release and dev-<short sha> otherwise, which means every image can
name itself, not just tagged ones.
The assertion runs on every image build, pull requests included, rather than
only on a publish. That is the #559 lesson applied: the manifest check in this
same workflow was gated to publishes, never ran, and failed a correct manifest
the first time it did.
Verified by building the image locally on arm64 with the arg set: orlyc
reports the stamped string and the assertion as written passes.
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.
Found by the
v0.1.0-rc1candidate, which is exactly what it was cut for.The symptom
A release candidate whose binary cannot say which release it is.
Why
make versionderives the string fromgit describe --tags --match 'v[0-9]*', and.dockerignoreexcludes.git— deliberately; it is build context nothing in the image needs. So inside the image build there has never been anything to describe, and the Dockerfile said so:That was a reasonable trade and it held while the image was only ever
:latest. It stops holding at a release. The tag carries the version only for someone who pulled a tag; the README tells people to run:latest, and they have no way to ask the binary what they have.The change
ARG ORLY_VERSION— when set, writesorly/build_version.hdirectly; when not, falls back tomake versionexactly as before, so a baredocker build .is unaffected.dev-<short sha>otherwise. So every image can name itself, not only tagged ones — which is the case that actually bothered me, since:latestmoves.That placement is deliberate. The manifest check in this same workflow was gated to publishes only, so it never ran and failed a correct manifest the first time it did (#559). A check that only runs on the rare path is a check you find out about at the worst moment.
Verification
Built the image locally on native arm64 with the arg set, then ran the assertion exactly as the workflow spells it:
Both branches of the conditional were checked for selection, so the no-arg fallback still takes the
make versionpath.Sequence
v0.1.0-rc2after this lands, to confirm the stamp survives a real tagged publish, thenv0.1.0.