Skip to content

Conversation

milosgajdos
Copy link
Member

We changed what we print in the version info in #4204

But we haven't updated the Dockerfile. This PR fixes that.

The output now:

$ make image
docker buildx bake --set "*.tags=distribution/distribution:latest" image-local
[+] Building 77.7s (22/22) FINISHED                                                                                                                                                                                                                                   
...
...

$ docker run -it distribution/distribution --version
registry github.com/distribution/distribution/v3 3.0.0-alpha.1-13-gfb6ccc33.m

Signed-off-by: Milos Gajdos <milosthegajdos@gmail.com>
@@ -16,7 +16,7 @@ FROM base AS version
ARG PKG=github.com/distribution/distribution/v3
RUN --mount=target=. \
VERSION=$(git describe --match 'v[0-9]*' --dirty='.m' --always --tags) REVISION=$(git rev-parse HEAD)$(if ! git diff --no-ext-diff --quiet --exit-code; then echo .m; fi); \
echo "-X ${PKG}/version.Version=${VERSION#v} -X ${PKG}/version.Revision=${REVISION} -X ${PKG}/version.Package=${PKG}" | tee /tmp/.ldflags; \
echo "-X ${PKG}/version.version=${VERSION#v} -X ${PKG}/version.revision=${REVISION} -X ${PKG}/version.mainpkg=${PKG}" | tee /tmp/.ldflags; \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, does that work with non-exported fields? TIL; thought they had to be exported for the -X functions to work, but perhaps that's just what I'm used to 😂

We should start looking if we can use go's built-in metadata for this (although I think that's producing versions based on the module version, not specifically git state, and we'd probably still want to have options to override these)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the comment in @corhere's original PR

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@milosgajdos
Copy link
Member Author

PTAL @corhere @wy65701436 @Jamstah

@milosgajdos milosgajdos merged commit dd32792 into distribution:main Jan 16, 2024
@milosgajdos milosgajdos deleted the update-dockerfile branch January 16, 2024 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants