Skip to content

Commit

Permalink
Pass VERSION variable to binary build targets.
Browse files Browse the repository at this point in the history
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
  • Loading branch information
cpuguy83 committed Oct 30, 2019
1 parent e7d2d85 commit c057825
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
21 changes: 15 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c057825

Please sign in to comment.