From 151ec207b945fd5644ac296a3e8735732904d805 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 28 Jan 2021 12:06:35 +0100 Subject: [PATCH] Makefile: install buildx from binary release, instead of building This was originally added in 833444c0d605b0cf86bc9dbdb436601434fd3493, at which time buildx did not yet have a release, so we had to build from source. Now that buildx has binary releases on GitHub, we should be able to consume those binaries instead of building. Signed-off-by: Sebastiaan van Stijn --- Dockerfile.buildx | 26 -------------------------- Makefile | 20 +++----------------- 2 files changed, 3 insertions(+), 43 deletions(-) delete mode 100644 Dockerfile.buildx diff --git a/Dockerfile.buildx b/Dockerfile.buildx deleted file mode 100644 index d3a46964dd..0000000000 --- a/Dockerfile.buildx +++ /dev/null @@ -1,26 +0,0 @@ -ARG GO_VERSION=1.13.15 -ARG BUILDX_COMMIT=v0.5.1 -ARG BUILDX_REPO=https://github.com/docker/buildx.git - -FROM golang:${GO_VERSION}-buster AS build -ARG BUILDX_REPO -RUN git clone "${BUILDX_REPO}" /buildx -WORKDIR /buildx -ARG BUILDX_COMMIT -RUN git fetch origin "${BUILDX_COMMIT}":build && git checkout build -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}" 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 -mod=vendor -ldflags "${ldflags}" -o /usr/bin/buildx ./cmd/buildx - -FROM golang:${GO_VERSION}-buster -COPY --from=build /usr/bin/buildx /usr/bin/buildx -ENTRYPOINT ["/usr/bin/buildx"] diff --git a/Makefile b/Makefile index 4ad8c8ab85..2ccde3c7d7 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,7 @@ .PHONY: all binary dynbinary build cross help install manpages run shell test test-docker-py test-integration test-unit validate win +BUILDX_VERSION ?= v0.5.1 + ifdef USE_BUILDX BUILDX ?= $(shell command -v buildx) BUILDX ?= $(shell command -v docker-buildx) @@ -273,22 +275,6 @@ buildx: bundles/buildx ## build buildx cli tool endif endif -# This intentionally is not using the `--output` flag from the docker CLI, which -# is a buildkit option. The idea here being that if buildx is being used, it's -# because buildkit is not supported natively bundles/buildx: bundles ## build buildx CLI tool - docker build -f $${BUILDX_DOCKERFILE:-Dockerfile.buildx} -t "moby-buildx:$${BUILDX_COMMIT:-latest}" \ - --build-arg BUILDX_COMMIT \ - --build-arg BUILDX_REPO \ - --build-arg GOOS=$$(if [ -n "$(GOOS)" ]; then echo $(GOOS); else go env GOHOSTOS || uname | awk '{print tolower($$0)}' || true; fi) \ - --build-arg GOARCH=$$(if [ -n "$(GOARCH)" ]; then echo $(GOARCH); else go env GOHOSTARCH || true; fi) \ - . - - id=$$(docker create moby-buildx:$${BUILDX_COMMIT:-latest}); \ - if [ -n "$${id}" ]; then \ - docker cp $${id}:/usr/bin/buildx $@ \ - && touch $@; \ - docker rm -f $${id}; \ - fi - + curl -fsSL https://raw.githubusercontent.com/moby/buildkit/70deac12b5857a1aa4da65e90b262368e2f71500/hack/install-buildx | VERSION="$(BUILDX_VERSION)" BINDIR="$(@D)" bash $@ version