1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/Dockerfile.buildx
Brian Goff 833444c0d6 Use buildx as Makefile builder
Since the dockerfile now requires buildkit, let's just use buildx can
bootstrap itself into even an old version of Docker which does not
support buildkit.

This also decouples the Dockerfile/build from the version of Docker
which is installed.

One major downside:

If buildx needs to setup a container driver (ie, docker does not support
buildkit), the `make shell` target (and others which call
`DOCKER_RUN_DOCKER`) must export the image from buildkit and into
docker. This added an extra 70s to a full build for me (agan only for targets
which call `DOCKER_RUN_DOCKER`) and 40s on a rebuild (with no changes).

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2019-10-03 14:07:00 -07:00

14 lines
No EOL
740 B
Text

ARG GO_VERSION=1.12.10
FROM golang:${GO_VERSION}-stretch
ARG BUILDX_REPO=https://github.com/docker/buildx.git
RUN git clone "${BUILDX_REPO}" /buildx
WORKDIR /buildx
ARG BUILDX_COMMIT=master
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"]