Use BuildKit to skip source code COPY if BIND_DIR set
build the final stage of the Dockerfile (including COPY ...) if no BIND_DIR
is used.
if BIND_DIR is used, build the dev stage, thus skipping the COPY.
Original author: @thaJeztah
Signed-off-by: Mohammad Nasirifar <farnasirim@gmail.com>
(cherry picked from commit e6d7df2e5d
)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
ecc423df7f
commit
e5a039169f
2 changed files with 7 additions and 1 deletions
|
@ -245,5 +245,7 @@ WORKDIR /go/src/github.com/docker/docker
|
||||||
VOLUME /var/lib/docker
|
VOLUME /var/lib/docker
|
||||||
# Wrap all commands in the "docker-in-docker" script to allow nested containers
|
# Wrap all commands in the "docker-in-docker" script to allow nested containers
|
||||||
ENTRYPOINT ["hack/dind"]
|
ENTRYPOINT ["hack/dind"]
|
||||||
|
|
||||||
|
FROM dev AS final
|
||||||
# Upload docker source
|
# Upload docker source
|
||||||
COPY . /go/src/github.com/docker/docker
|
COPY . /go/src/github.com/docker/docker
|
||||||
|
|
6
Makefile
6
Makefile
|
@ -34,6 +34,7 @@ DOCKER_ENVS := \
|
||||||
-e KEEPBUNDLE \
|
-e KEEPBUNDLE \
|
||||||
-e DOCKER_BUILD_ARGS \
|
-e DOCKER_BUILD_ARGS \
|
||||||
-e DOCKER_BUILD_GOGC \
|
-e DOCKER_BUILD_GOGC \
|
||||||
|
-e DOCKER_BUILD_OPTS \
|
||||||
-e DOCKER_BUILD_PKGS \
|
-e DOCKER_BUILD_PKGS \
|
||||||
-e DOCKER_BUILDKIT \
|
-e DOCKER_BUILDKIT \
|
||||||
-e DOCKER_BASH_COMPLETION_PATH \
|
-e DOCKER_BASH_COMPLETION_PATH \
|
||||||
|
@ -116,6 +117,9 @@ INTERACTIVE := $(shell [ -t 0 ] && echo 1 || echo 0)
|
||||||
ifeq ($(INTERACTIVE), 1)
|
ifeq ($(INTERACTIVE), 1)
|
||||||
DOCKER_FLAGS += -t
|
DOCKER_FLAGS += -t
|
||||||
endif
|
endif
|
||||||
|
ifeq ($(BIND_DIR), .)
|
||||||
|
DOCKER_BUILD_OPTS += --target=dev
|
||||||
|
endif
|
||||||
|
|
||||||
DOCKER_RUN_DOCKER := $(DOCKER_FLAGS) "$(DOCKER_IMAGE)"
|
DOCKER_RUN_DOCKER := $(DOCKER_FLAGS) "$(DOCKER_IMAGE)"
|
||||||
|
|
||||||
|
@ -132,7 +136,7 @@ dynbinary: build ## build the linux dynbinaries
|
||||||
|
|
||||||
build: bundles
|
build: bundles
|
||||||
$(warning The docker client CLI has moved to github.com/docker/cli. For a dev-test cycle involving the CLI, run:${\n} DOCKER_CLI_PATH=/host/path/to/cli/binary make shell ${\n} then change the cli and compile into a binary at the same location.${\n})
|
$(warning The docker client CLI has moved to github.com/docker/cli. For a dev-test cycle involving the CLI, run:${\n} DOCKER_CLI_PATH=/host/path/to/cli/binary make shell ${\n} then change the cli and compile into a binary at the same location.${\n})
|
||||||
docker build ${BUILD_APT_MIRROR} ${DOCKER_BUILD_ARGS} -t "$(DOCKER_IMAGE)" -f "$(DOCKERFILE)" .
|
docker build ${BUILD_APT_MIRROR} ${DOCKER_BUILD_ARGS} ${DOCKER_BUILD_OPTS} -t "$(DOCKER_IMAGE)" -f "$(DOCKERFILE)" .
|
||||||
|
|
||||||
bundles:
|
bundles:
|
||||||
mkdir bundles
|
mkdir bundles
|
||||||
|
|
Loading…
Add table
Reference in a new issue