make buildx: fix variable substitution and version

The variables were not substituted, because single-quotes were used.
While at it; change the fixed version/commit to use the actual commit
and version, using git.

before this change:

    make buildx && ./bundles/buildx version
    github.com/docker/buildx ${BUILDX_COMMIT} ${BUILDX_COMMIT}

after this change:

    make buildx && ./bundles/buildx version
    buildx v0.3.0 c967f1d

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2019-10-14 13:34:28 +02:00
parent c110283004
commit ce28a91cca
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C

View file

@ -10,5 +10,12 @@ ARG GOOS
ARG GOARCH
# Keep these essentially no-op var settings for debug purposes.
# It allows us to see what the GOOS/GOARCH that's being built for is.
RUN GOOS=${GOOS} GOARCH=${GOARCH} go build -ldflags '-X github.com/docker/buildx/version.Version=${BUILDX_COMMIT} -X github.com/docker/buildx/version.Revision=${BUILDX_COMMIT} -X github.com/docker/buildx/version.Package=github.com/docker/buildx' -o /usr/bin/buildx ./cmd/buildx
ENTRYPOINT ["/usr/bin/buildx"]
RUN GOOS="${GOOS}" GOARCH="${GOARCH}" BUILDX_COMMIT="${BUILDX_COMMIT}"; \
pkg="github.com/docker/buildx"; \
ldflags="\
-X \"${pkg}/version.Version=$(git describe --tags)\" \
-X \"${pkg}/version.Revision=$(git rev-parse --short HEAD)\" \
-X \"${pkg}/version.Package=buildx\" \
"; \
go build -ldflags "${ldflags}" -o /usr/bin/buildx ./cmd/buildx
ENTRYPOINT ["/usr/bin/buildx"]