Browse code

Fix trick for `make BINDDIR=. shell` and `COPY .`

This was inadvertently removed when updating the Dockerfile for buildkit
specific features.

Trick selects a different build target depending on if the source is
going to be bind-mounted in anyway, which prevents the need to copy the
whole source tree to the builder.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>

Brian Goff authored on 2019/10/09 03:17:15
Showing 2 changed files
... ...
@@ -299,19 +299,21 @@ WORKDIR /go/src/github.com/docker/docker
299 299
 VOLUME /var/lib/docker
300 300
 # Wrap all commands in the "docker-in-docker" script to allow nested containers
301 301
 ENTRYPOINT ["hack/dind"]
302
+
303
+FROM dev AS src
302 304
 COPY . /go/src/github.com/docker/docker
303 305
 
304
-FROM dev AS build-binary
306
+FROM src AS build-binary
305 307
 ARG DOCKER_GITCOMMIT=HEAD
306 308
 RUN --mount=type=cache,target=/root/.cache/go-build \
307 309
 	hack/make.sh binary
308 310
 
309
-FROM dev AS build-dynbinary
311
+FROM src AS build-dynbinary
310 312
 ARG DOCKER_GITCOMMIT=HEAD
311 313
 RUN --mount=type=cache,target=/root/.cache/go-build \
312 314
 	hack/make.sh dynbinary
313 315
 
314
-FROM dev AS build-cross
316
+FROM src AS build-cross
315 317
 ARG DOCKER_GITCOMMIT=HEAD
316 318
 ARG DOCKER_CROSSPLATFORMS=""
317 319
 RUN --mount=type=cache,target=/root/.cache/go-build \
... ...
@@ -326,4 +328,4 @@ COPY --from=build-dynbinary /go/src/github.com/docker/docker/bundles/ /
326 326
 FROM scratch AS cross
327 327
 COPY --from=build-cross /go/src/github.com/docker/docker/bundles/ /
328 328
 
329
-FROM dev AS final
329
+FROM src AS final
... ...
@@ -187,7 +187,11 @@ install: ## install the linux binaries
187 187
 run: build ## run the docker daemon in a container
188 188
 	$(DOCKER_RUN_DOCKER) sh -c "KEEPBUNDLE=1 hack/make.sh install-binary run"
189 189
 
190
+ifeq ($(BIND_DIR), .)
190 191
 shell: DOCKER_BUILD_ARGS += --target=dev
192
+else
193
+shell: DOCKER_BUILD_ARGS += --target=final
194
+endif
191 195
 shell: BUILDX_BUILD_EXTRA_OPTS += --load
192 196
 shell: build  ## start a shell inside the build env
193 197
 	$(DOCKER_RUN_DOCKER) bash