Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40089 from thaJeztah/fix_buildx_target
Fix various issues with the "make buildx" target
- Loading branch information
Showing
3 changed files
with
56 additions
and
23 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,27 @@ | ||
ARG GO_VERSION=1.12.10 | ||
FROM golang:${GO_VERSION}-stretch | ||
ARG BUILDX_COMMIT=v0.3.1 | ||
ARG BUILDX_REPO=https://github.com/docker/buildx.git | ||
|
||
FROM golang:${GO_VERSION}-stretch AS build | ||
ARG BUILDX_REPO | ||
RUN git clone "${BUILDX_REPO}" /buildx | ||
WORKDIR /buildx | ||
ARG BUILDX_COMMIT=master | ||
ARG BUILDX_COMMIT | ||
RUN git fetch origin "${BUILDX_COMMIT}":build && git checkout build | ||
RUN go mod download | ||
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 | ||
|
||
FROM golang:${GO_VERSION}-stretch | ||
COPY --from=build /usr/bin/buildx /usr/bin/buildx | ||
ENTRYPOINT ["/usr/bin/buildx"] |
This file contains 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
This file contains 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