Pass VERSION variable to binary build targets.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
Brian Goff 2019-10-16 10:09:10 -07:00
parent e7d2d853f6
commit c057825cf5
2 changed files with 19 additions and 7 deletions

View File

@ -315,19 +315,28 @@ ENTRYPOINT ["hack/dind"]
FROM dev AS src
COPY . /go/src/github.com/docker/docker
FROM src AS build-binary
FROM src AS binary-base
ARG DOCKER_GITCOMMIT=HEAD
ENV DOCKER_GITCOMMIT=${DOCKER_GITCOMMIT}
ARG VERSION
ENV VERSION=${VERSION}
ARG PLATFORM
ENV PLATFORM=${PLATFORM}
ARG PRODUCT
ENV PRODUCT=${PRODUCT}
ARG DEFAULT_PRODUCT_LICENSE
ENV DEFAULT_PRODUCT_LICENSE=${DEFAULT_PRODUCT_LICENSE}
FROM binary-base AS build-binary
RUN --mount=type=cache,target=/root/.cache/go-build \
hack/make.sh binary
FROM src AS build-dynbinary
ARG DOCKER_GITCOMMIT=HEAD
FROM binary-base AS build-dynbinary
RUN --mount=type=cache,target=/root/.cache/go-build \
hack/make.sh dynbinary
FROM src AS build-cross
ARG DOCKER_GITCOMMIT=HEAD
ARG DOCKER_CROSSPLATFORMS=""
FROM binary-base AS build-cross
ARG DOCKER_CROSSPLATFORMS
RUN --mount=type=cache,target=/root/.cache/go-build \
hack/make.sh cross

View File

@ -158,6 +158,8 @@ ifdef DOCKER_CROSSPLATFORMS
BUILD_CROSS = --build-arg CROSS=true
endif
VERSION_AUTOGEN_ARGS = --build-arg VERSION --build-arg DOCKER_GITCOMMIT --build-arg PRODUCT --build-arg PLATFORM --build-arg DEFAULT_PRODUCT_LICENSE
default: binary
all: build ## validate all checks, build linux binaries, run all tests\ncross build non-linux binaries and generate archives
@ -170,7 +172,7 @@ cross: ## cross build the binaries for darwin, freebsd and\nwindows
cross: BUILD_OPTS += --build-arg CROSS=true --build-arg DOCKER_CROSSPLATFORMS
binary dynbinary cross: buildx
$(BUILD_CMD) $(BUILD_OPTS) --output=bundles/ --target=$@ .
$(BUILD_CMD) $(BUILD_OPTS) --output=bundles/ --target=$@ $(VERSION_AUTOGEN_ARGS) .
build: target = --target=final
ifdef USE_BUILDX
@ -264,6 +266,7 @@ ifdef USE_BUILDX
ifeq ($(BUILDX), bundles/buildx)
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