Skip to content

Update Dockerfile to skip source copy for speed up#38370

Merged
thaJeztah merged 1 commit intomoby:masterfrom
farnasirim:36413-bind-dir-skip-copy
Dec 29, 2018
Merged

Update Dockerfile to skip source copy for speed up#38370
thaJeztah merged 1 commit intomoby:masterfrom
farnasirim:36413-bind-dir-skip-copy

Conversation

@farnasirim
Copy link
Copy Markdown
Contributor

Will skip the COPY command which copies the whole source code to
the container if BIND_DIR=. is supplied to the make command to
speed up the development build.

Also update .gitignore, add *.tmp, to stop git from tracking
Dockerfile.dev.tmp which is created in the above process, and
any other .tmp file in the future.

Signed-off-by: Mohammad Nasirifar farnasirim@gmail.com

Addresses the requirement raised in #36413 and closes #36413.

- A picture of a cute animal (not mandatory but encouraged)

Sorry, no punch line

Copy link
Copy Markdown
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this! I don't think patching the Dockerfile is the right approach though; I left a comment below with an alternative approach; let me know what you think, and feel free to use that patch instead for your PR 👍

Makefile Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes, this is similar to what I tried in #29298.

However, with BuildKit now being an option, which sends the build-context "on demand" (instead of always sending the build-context), I think this should be done in a different way (also see #36413); this patch will;

  • 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 ...
diff --git a/.gitignore b/.gitignore
index 6e5b3d1214..392bf963c5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,7 +4,6 @@
 *.exe
 *.exe~
 *.orig
-*.tmp
 test.main
 .*.swp
 .DS_Store
diff --git a/Dockerfile b/Dockerfile
index 8337653e19..2573c61c33 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -236,5 +236,7 @@ WORKDIR /go/src/github.com/docker/docker
 VOLUME /var/lib/docker
 # Wrap all commands in the "docker-in-docker" script to allow nested containers
 ENTRYPOINT ["hack/dind"]
+
+FROM dev AS final
 # Upload docker source
 COPY . /go/src/github.com/docker/docker
diff --git a/Makefile b/Makefile
index 7028a65274..a7d42092f6 100644
--- a/Makefile
+++ b/Makefile
@@ -29,6 +29,7 @@ DOCKER_ENVS := \
        -e KEEPBUNDLE \
        -e DOCKER_BUILD_ARGS \
        -e DOCKER_BUILD_GOGC \
+       -e DOCKER_BUILD_OPTS \
        -e DOCKER_BUILD_PKGS \
        -e DOCKER_BUILDKIT \
        -e DOCKER_BASH_COMPLETION_PATH \
@@ -108,6 +109,9 @@ INTERACTIVE := $(shell [ -t 0 ] && echo 1 || echo 0)
 ifeq ($(INTERACTIVE), 1)
        DOCKER_FLAGS += -t
 endif
+ifeq ($(BIND_DIR), .)
+       DOCKER_BUILD_OPTS += --target=dev
+endif
 
 DOCKER_RUN_DOCKER := $(DOCKER_FLAGS) "$(DOCKER_IMAGE)"
 
@@ -124,15 +128,7 @@ dynbinary: build ## build the linux dynbinaries
 
 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})
-ifeq ($(BIND_DIR), .)
-# BIND_DIR set to CWD: will refrain from copying the code to the
-# container since CWD will be mounted as a volume.
-       sed -e 's/COPY\ \./\# COPY\ \./g' "$(DOCKERFILE)" > "$(DOCKERFILE_DEV_TMP)"
-       docker build ${BUILD_APT_MIRROR} ${DOCKER_BUILD_ARGS} -t "$(DOCKER_IMAGE)" -f "$(DOCKERFILE_DEV_TMP)" .
-       rm "$(DOCKERFILE_DEV_TMP)"
-else
-       docker build ${BUILD_APT_MIRROR} ${DOCKER_BUILD_ARGS} -t "$(DOCKER_IMAGE)" -f "$(DOCKERFILE)" .
-endif
+       docker build ${BUILD_APT_MIRROR} ${DOCKER_BUILD_ARGS} ${DOCKER_BUILD_OPTS} -t "$(DOCKER_IMAGE)" -f "$(DOCKERFILE)" .
 
 bundles:
        mkdir bundles

With the patch above applied;

with BIND_DIR and DOCKER_BUILDKIT=1
export DOCKER_BUILDKIT=1
make BIND_DIR=. shell
Makefile:130: The docker client CLI has moved to github.com/docker/cli. For a dev-test cycle involving the CLI, run:
 DOCKER_CLI_PATH=/host/path/to/cli/binary make shell 
 then change the cli and compile into a binary at the same location.

docker build   --target=dev -t "docker-dev:farnasirim-36413-bind-dir-skip-copy" -f "Dockerfile" .
[+] Building 0.2s (59/59) FINISHED                                                                                                                                                                                                 
 => [internal] load build definition from Dockerfile                                                                                                                                                                          0.0s
 => => transferring dockerfile: 9.10kB                                                                                                                                                                                        0.0s
 => [internal] load .dockerignore                                                                                                                                                                                             0.1s
 => => transferring context: 34B                                                                                                                                                                                              0.0s
 => [internal] load metadata for docker.io/library/golang:1.11.2                                                                                                                                                              0.0s
 => [internal] helper image for file operations                                                                                                                                                                               0.0s
 => [internal] load build context                                                                                                                                                                                             0.0s
 => => transferring context: 725B                                                                                                                                                                                             0.0s
 => [base 1/2] FROM docker.io/library/golang:1.11.2                                                                                                                                                                           0.0s
 => CACHED [base 2/2] RUN sed -ri s/(httpredir|deb).debian.org/deb.debian.org/g /etc/apt/sources.list                                                                                                                         0.0s
 => CACHED [runtime-dev 1/1] RUN apt-get update && apt-get install -y  libapparmor-dev  libseccomp-dev                                                                                                                        0.0s
 => CACHED [dev 1/21] RUN groupadd -r docker                                                                                                                                                                                  0.0s
 => CACHED [dev 2/21] RUN useradd --create-home --gid docker unprivilegeduser                                                                                                                                                 0.0s
 => CACHED [dev 3/21] RUN ln -sfv /go/src/github.com/docker/docker/.bashrc ~/.bashrc                                                                                                                                          0.0s
 => CACHED [dev 4/21] RUN echo source /usr/share/bash-completion/bash_completion >> /etc/bash.bashrc                                                                                                                          0.0s
 => CACHED [dev 5/21] RUN ln -s /usr/local/completion/bash/docker /etc/bash_completion.d/docker                                                                                                                               0.0s
 => CACHED [dev 6/21] RUN ldconfig                                                                                                                                                                                            0.0s
 => CACHED [dev 7/21] RUN apt-get update && apt-get install -y  apparmor  aufs-tools  bash-completion  btrfs-tools  iptables  jq  libcap2-bin  libdevmapper-dev  libudev-dev  libsystemd-dev  binutils-mingw-w64  g++-mingw-  0.0s
 => CACHED [swagger 1/1] RUN set -x  && export GOPATH=$(mktemp -d)  && git clone https://github.com/go-swagger/go-swagger.git /go/src/github.com/go-swagger/go-swagger  && (cd /go/src/github.com/go-swagger/go-swagger && g  0.0s
 => CACHED [dev 8/21] COPY --from=swagger /build/swagger* /usr/local/bin/                                                                                                                                                     0.0s
 => CACHED [frozen-images 1/3] RUN apt-get update && apt-get install -y jq ca-certificates --no-install-recommends                                                                                                            0.0s
 => CACHED [frozen-images 2/3] COPY contrib/download-frozen-image-v2.sh /                                                                                                                                                     0.0s
 => CACHED [frozen-images 3/3] RUN /download-frozen-image-v2.sh /build  buildpack-deps:jessie@sha256:dd86dced7c9cd2a724e779730f0a53f93b7ef42228d4344b25ce9a42a1486251  busybox:latest@sha256:bbc3a03235220b170ba48a157dd097d  0.0s
 => CACHED [dev 9/21] COPY --from=frozen-images /build/ /docker-frozen-images                                                                                                                                                 0.0s
 => CACHED [gometalinter 1/3] COPY hack/dockerfile/install/install.sh ./install.sh                                                                                                                                            0.0s
 => CACHED [gometalinter 2/3] COPY hack/dockerfile/install/gometalinter.installer ./                                                                                                                                          0.0s
 => CACHED [gometalinter 3/3] RUN PREFIX=/build/ ./install.sh gometalinter                                                                                                                                                    0.0s
 => CACHED [dev 10/21] COPY --from=gometalinter /build/ /usr/local/bin/                                                                                                                                                       0.0s
 => CACHED [tomlv 2/3] COPY hack/dockerfile/install/tomlv.installer ./                                                                                                                                                        0.0s
 => CACHED [tomlv 3/3] RUN PREFIX=/build/ ./install.sh tomlv                                                                                                                                                                  0.0s
 => CACHED [dev 11/21] COPY --from=tomlv /build/ /usr/local/bin/                                                                                                                                                              0.0s
 => CACHED [vndr 2/3] COPY hack/dockerfile/install/vndr.installer ./                                                                                                                                                          0.0s
 => CACHED [vndr 3/3] RUN PREFIX=/build/ ./install.sh vndr                                                                                                                                                                    0.0s
 => CACHED [dev 12/21] COPY --from=vndr /build/ /usr/local/bin/                                                                                                                                                               0.0s
 => CACHED [tini 1/4] RUN apt-get update && apt-get install -y cmake vim-common                                                                                                                                               0.0s
 => CACHED [tini 2/4] COPY hack/dockerfile/install/install.sh ./install.sh                                                                                                                                                    0.0s
 => CACHED [tini 3/4] COPY hack/dockerfile/install/tini.installer ./                                                                                                                                                          0.0s
 => CACHED [tini 4/4] RUN PREFIX=/build/ ./install.sh tini                                                                                                                                                                    0.0s
 => CACHED [dev 13/21] COPY --from=tini /build/ /usr/local/bin/                                                                                                                                                               0.0s
 => CACHED [runc 1/3] COPY hack/dockerfile/install/install.sh ./install.sh                                                                                                                                                    0.0s
 => CACHED [runc 2/3] COPY hack/dockerfile/install/runc.installer ./                                                                                                                                                          0.0s
 => CACHED [runc 3/3] RUN PREFIX=/build/ ./install.sh runc                                                                                                                                                                    0.0s
 => CACHED [dev 14/21] COPY --from=runc /build/ /usr/local/bin/                                                                                                                                                               0.0s
 => CACHED [containerd 1/4] RUN apt-get update && apt-get install -y btrfs-tools                                                                                                                                              0.0s
 => CACHED [containerd 2/4] COPY hack/dockerfile/install/install.sh ./install.sh                                                                                                                                              0.0s
 => CACHED [containerd 3/4] COPY hack/dockerfile/install/containerd.installer ./                                                                                                                                              0.0s
 => CACHED [containerd 4/4] RUN PREFIX=/build/ ./install.sh containerd                                                                                                                                                        0.0s
 => CACHED [dev 15/21] COPY --from=containerd /build/ /usr/local/bin/                                                                                                                                                         0.0s
 => CACHED [proxy 2/3] COPY hack/dockerfile/install/proxy.installer ./                                                                                                                                                        0.0s
 => CACHED [proxy 3/3] RUN PREFIX=/build/ ./install.sh proxy                                                                                                                                                                  0.0s
 => CACHED [dev 16/21] COPY --from=proxy /build/ /usr/local/bin/                                                                                                                                                              0.0s
 => CACHED [dockercli 2/3] COPY hack/dockerfile/install/dockercli.installer ./                                                                                                                                                0.0s
 => CACHED [dockercli 3/3] RUN PREFIX=/build/ ./install.sh dockercli                                                                                                                                                          0.0s
 => CACHED [dev 17/21] COPY --from=dockercli /build/ /usr/local/cli                                                                                                                                                           0.0s
 => CACHED [registry 1/1] RUN set -x  && export GOPATH=$(mktemp -d)  && git clone https://github.com/docker/distribution.git /go/src/github.com/docker/distribution  && (cd /go/src/github.com/docker/distribution && git ch  0.0s
 => CACHED [dev 18/21] COPY --from=registry /build/registry* /usr/local/bin/                                                                                                                                                  0.0s
 => CACHED [criu 1/1] RUN apt-get update && apt-get install -y  libnet-dev  libprotobuf-c0-dev  libprotobuf-dev  libnl-3-dev  libcap-dev  protobuf-compiler  protobuf-c-compiler  python-protobuf  && mkdir -p /usr/src/criu  0.0s
 => CACHED [dev 19/21] COPY --from=criu /build/ /usr/local/                                                                                                                                                                   0.0s
 => CACHED [docker-py 1/1] RUN git clone https://github.com/docker/docker-py.git /build  && cd /build  && git checkout -q 8b246db271a85d6541dc458838627e89c683e42f                                                            0.0s
 => CACHED [dev 20/21] COPY --from=docker-py /build/ /docker-py                                                                                                                                                               0.0s
 => CACHED [dev 21/21] RUN cd /docker-py  && pip install docker-pycreds==0.2.1  && pip install yamllint==1.5.0  && pip install -r test-requirements.txt                                                                       0.0s
 => exporting to image                                                                                                                                                                                                        0.1s
 => => exporting layers                                                                                                                                                                                                       0.0s
 => => writing image sha256:944958adb617bd99efa3a293bf17c79c61bc3db4a2c376fbcb3a4854bac83150                                                                                                                                  0.0s
 => => naming to docker.io/library/docker-dev:farnasirim-36413-bind-dir-skip-copy                                                                                                                                             0.0s
docker run --rm -i --privileged  -e DOCKER_CROSSPLATFORMS -e BUILD_APT_MIRROR -e BUILDFLAGS -e KEEPBUNDLE -e DOCKER_BUILD_ARGS -e DOCKER_BUILD_GOGC -e DOCKER_BUILD_OPTS -e DOCKER_BUILD_PKGS -e DOCKER_BUILDKIT -e DOCKER_BASH_COMPLETION_PATH -e DOCKER_CLI_PATH -e DOCKER_DEBUG -e DOCKER_EXPERIMENTAL -e DOCKER_GITCOMMIT -e DOCKER_GRAPHDRIVER -e DOCKER_LDFLAGS -e DOCKER_PORT -e DOCKER_REMAP_ROOT -e DOCKER_STORAGE_OPTS -e DOCKER_USERLANDPROXY -e DOCKERD_ARGS -e TEST_INTEGRATION_DIR -e TESTDIRS -e TESTFLAGS -e TIMEOUT -e HTTP_PROXY -e HTTPS_PROXY -e NO_PROXY -e http_proxy -e https_proxy -e no_proxy -e VERSION -e PLATFORM -e DEFAULT_PRODUCT_LICENSE -e PRODUCT -v "/Users/sebastiaan/go/src/github.com/docker/docker/.:/go/src/github.com/docker/docker/." -v "/Users/sebastiaan/go/src/github.com/docker/docker/.git:/go/src/github.com/docker/docker/.git" -v docker-dev-cache:/root/.cache    -t "docker-dev:farnasirim-36413-bind-dir-skip-copy" bash
root@5b9549f8d6d3:/go/src/github.com/docker/docker#
Without BIND_DIR, but DOCKER_BUILDKIT=0
export DOCKER_BUILDKIT=1
make shell
Makefile:130: The docker client CLI has moved to github.com/docker/cli. For a dev-test cycle involving the CLI, run:
 DOCKER_CLI_PATH=/host/path/to/cli/binary make shell 
 then change the cli and compile into a binary at the same location.

docker build    -t "docker-dev:farnasirim-36413-bind-dir-skip-copy" -f "Dockerfile" .
[+] Building 11.1s (60/60) FINISHED                                                                                                                                                                                                
 => [internal] load build definition from Dockerfile                                                                                                                                                                          0.0s
 => => transferring dockerfile: 37B                                                                                                                                                                                           0.0s
 => [internal] load .dockerignore                                                                                                                                                                                             0.0s
 => => transferring context: 34B                                                                                                                                                                                              0.0s
 => [internal] load metadata for docker.io/library/golang:1.11.2                                                                                                                                                              0.0s
 => [internal] load build context                                                                                                                                                                                             5.6s
 => => transferring context: 319.22MB                                                                                                                                                                                         5.3s
 => CACHED [internal] helper image for file operations                                                                                                                                                                        0.0s
 => [base 1/2] FROM docker.io/library/golang:1.11.2                                                                                                                                                                           0.0s
 => CACHED [base 2/2] RUN sed -ri s/(httpredir|deb).debian.org/deb.debian.org/g /etc/apt/sources.list                                                                                                                         0.0s
 => CACHED [runtime-dev 1/1] RUN apt-get update && apt-get install -y  libapparmor-dev  libseccomp-dev                                                                                                                        0.0s
 => CACHED [dev 1/21] RUN groupadd -r docker                                                                                                                                                                                  0.0s
 => CACHED [dev 2/21] RUN useradd --create-home --gid docker unprivilegeduser                                                                                                                                                 0.0s
 => CACHED [dev 3/21] RUN ln -sfv /go/src/github.com/docker/docker/.bashrc ~/.bashrc                                                                                                                                          0.0s
 => CACHED [dev 4/21] RUN echo source /usr/share/bash-completion/bash_completion >> /etc/bash.bashrc                                                                                                                          0.0s
 => CACHED [dev 5/21] RUN ln -s /usr/local/completion/bash/docker /etc/bash_completion.d/docker                                                                                                                               0.0s
 => CACHED [dev 6/21] RUN ldconfig                                                                                                                                                                                            0.0s
 => CACHED [dev 7/21] RUN apt-get update && apt-get install -y  apparmor  aufs-tools  bash-completion  btrfs-tools  iptables  jq  libcap2-bin  libdevmapper-dev  libudev-dev  libsystemd-dev  binutils-mingw-w64  g++-mingw-  0.0s
 => CACHED [swagger 1/1] RUN set -x  && export GOPATH=$(mktemp -d)  && git clone https://github.com/go-swagger/go-swagger.git /go/src/github.com/go-swagger/go-swagger  && (cd /go/src/github.com/go-swagger/go-swagger && g  0.0s
 => CACHED [dev 8/21] COPY --from=swagger /build/swagger* /usr/local/bin/                                                                                                                                                     0.0s
 => CACHED [frozen-images 1/3] RUN apt-get update && apt-get install -y jq ca-certificates --no-install-recommends                                                                                                            0.0s
 => CACHED [frozen-images 2/3] COPY contrib/download-frozen-image-v2.sh /                                                                                                                                                     0.0s
 => CACHED [frozen-images 3/3] RUN /download-frozen-image-v2.sh /build  buildpack-deps:jessie@sha256:dd86dced7c9cd2a724e779730f0a53f93b7ef42228d4344b25ce9a42a1486251  busybox:latest@sha256:bbc3a03235220b170ba48a157dd097d  0.0s
 => CACHED [dev 9/21] COPY --from=frozen-images /build/ /docker-frozen-images                                                                                                                                                 0.0s
 => CACHED [gometalinter 1/3] COPY hack/dockerfile/install/install.sh ./install.sh                                                                                                                                            0.0s
 => CACHED [gometalinter 2/3] COPY hack/dockerfile/install/gometalinter.installer ./                                                                                                                                          0.0s
 => CACHED [gometalinter 3/3] RUN PREFIX=/build/ ./install.sh gometalinter                                                                                                                                                    0.0s
 => CACHED [dev 10/21] COPY --from=gometalinter /build/ /usr/local/bin/                                                                                                                                                       0.0s
 => CACHED [tomlv 2/3] COPY hack/dockerfile/install/tomlv.installer ./                                                                                                                                                        0.0s
 => CACHED [tomlv 3/3] RUN PREFIX=/build/ ./install.sh tomlv                                                                                                                                                                  0.0s
 => CACHED [dev 11/21] COPY --from=tomlv /build/ /usr/local/bin/                                                                                                                                                              0.0s
 => CACHED [vndr 2/3] COPY hack/dockerfile/install/vndr.installer ./                                                                                                                                                          0.0s
 => CACHED [vndr 3/3] RUN PREFIX=/build/ ./install.sh vndr                                                                                                                                                                    0.0s
 => CACHED [dev 12/21] COPY --from=vndr /build/ /usr/local/bin/                                                                                                                                                               0.0s
 => CACHED [tini 1/4] RUN apt-get update && apt-get install -y cmake vim-common                                                                                                                                               0.0s
 => CACHED [tini 2/4] COPY hack/dockerfile/install/install.sh ./install.sh                                                                                                                                                    0.0s
 => CACHED [tini 3/4] COPY hack/dockerfile/install/tini.installer ./                                                                                                                                                          0.0s
 => CACHED [tini 4/4] RUN PREFIX=/build/ ./install.sh tini                                                                                                                                                                    0.0s
 => CACHED [dev 13/21] COPY --from=tini /build/ /usr/local/bin/                                                                                                                                                               0.0s
 => CACHED [runc 1/3] COPY hack/dockerfile/install/install.sh ./install.sh                                                                                                                                                    0.0s
 => CACHED [runc 2/3] COPY hack/dockerfile/install/runc.installer ./                                                                                                                                                          0.0s
 => CACHED [runc 3/3] RUN PREFIX=/build/ ./install.sh runc                                                                                                                                                                    0.0s
 => CACHED [dev 14/21] COPY --from=runc /build/ /usr/local/bin/                                                                                                                                                               0.0s
 => CACHED [containerd 1/4] RUN apt-get update && apt-get install -y btrfs-tools                                                                                                                                              0.0s
 => CACHED [containerd 2/4] COPY hack/dockerfile/install/install.sh ./install.sh                                                                                                                                              0.0s
 => CACHED [containerd 3/4] COPY hack/dockerfile/install/containerd.installer ./                                                                                                                                              0.0s
 => CACHED [containerd 4/4] RUN PREFIX=/build/ ./install.sh containerd                                                                                                                                                        0.0s
 => CACHED [dev 15/21] COPY --from=containerd /build/ /usr/local/bin/                                                                                                                                                         0.0s
 => CACHED [proxy 2/3] COPY hack/dockerfile/install/proxy.installer ./                                                                                                                                                        0.0s
 => CACHED [proxy 3/3] RUN PREFIX=/build/ ./install.sh proxy                                                                                                                                                                  0.0s
 => CACHED [dev 16/21] COPY --from=proxy /build/ /usr/local/bin/                                                                                                                                                              0.0s
 => CACHED [dockercli 2/3] COPY hack/dockerfile/install/dockercli.installer ./                                                                                                                                                0.0s
 => CACHED [dockercli 3/3] RUN PREFIX=/build/ ./install.sh dockercli                                                                                                                                                          0.0s
 => CACHED [dev 17/21] COPY --from=dockercli /build/ /usr/local/cli                                                                                                                                                           0.0s
 => CACHED [registry 1/1] RUN set -x  && export GOPATH=$(mktemp -d)  && git clone https://github.com/docker/distribution.git /go/src/github.com/docker/distribution  && (cd /go/src/github.com/docker/distribution && git ch  0.0s
 => CACHED [dev 18/21] COPY --from=registry /build/registry* /usr/local/bin/                                                                                                                                                  0.0s
 => CACHED [criu 1/1] RUN apt-get update && apt-get install -y  libnet-dev  libprotobuf-c0-dev  libprotobuf-dev  libnl-3-dev  libcap-dev  protobuf-compiler  protobuf-c-compiler  python-protobuf  && mkdir -p /usr/src/criu  0.0s
 => CACHED [dev 19/21] COPY --from=criu /build/ /usr/local/                                                                                                                                                                   0.0s
 => CACHED [docker-py 1/1] RUN git clone https://github.com/docker/docker-py.git /build  && cd /build  && git checkout -q 8b246db271a85d6541dc458838627e89c683e42f                                                            0.0s
 => CACHED [dev 20/21] COPY --from=docker-py /build/ /docker-py                                                                                                                                                               0.0s
 => CACHED [dev 21/21] RUN cd /docker-py  && pip install docker-pycreds==0.2.1  && pip install yamllint==1.5.0  && pip install -r test-requirements.txt                                                                       0.0s
 => [final 1/1] COPY . /go/src/github.com/docker/docker                                                                                                                                                                       3.3s
 => exporting to image                                                                                                                                                                                                        2.0s
 => => exporting layers                                                                                                                                                                                                       1.9s
 => => writing image sha256:368b8cedf2da965816084465d7bc6ff794ff1c3eedc35681b6d5a9a399fa718b                                                                                                                                  0.0s
 => => naming to docker.io/library/docker-dev:farnasirim-36413-bind-dir-skip-copy                                                                                                                                             0.0s
docker run --rm -i --privileged  -e DOCKER_CROSSPLATFORMS -e BUILD_APT_MIRROR -e BUILDFLAGS -e KEEPBUNDLE -e DOCKER_BUILD_ARGS -e DOCKER_BUILD_GOGC -e DOCKER_BUILD_OPTS -e DOCKER_BUILD_PKGS -e DOCKER_BUILDKIT -e DOCKER_BASH_COMPLETION_PATH -e DOCKER_CLI_PATH -e DOCKER_DEBUG -e DOCKER_EXPERIMENTAL -e DOCKER_GITCOMMIT -e DOCKER_GRAPHDRIVER -e DOCKER_LDFLAGS -e DOCKER_PORT -e DOCKER_REMAP_ROOT -e DOCKER_STORAGE_OPTS -e DOCKER_USERLANDPROXY -e DOCKERD_ARGS -e TEST_INTEGRATION_DIR -e TESTDIRS -e TESTFLAGS -e TIMEOUT -e HTTP_PROXY -e HTTPS_PROXY -e NO_PROXY -e http_proxy -e https_proxy -e no_proxy -e VERSION -e PLATFORM -e DEFAULT_PRODUCT_LICENSE -e PRODUCT -v "/Users/sebastiaan/go/src/github.com/docker/docker/bundles:/go/src/github.com/docker/docker/bundles" -v "/Users/sebastiaan/go/src/github.com/docker/docker/.git:/go/src/github.com/docker/docker/.git" -v docker-dev-cache:/root/.cache    -t "docker-dev:farnasirim-36413-bind-dir-skip-copy" bash
With BIND_DIR, but DOCKER_BUILDKIT=0
export DOCKER_BUILDKIT=0
make BIND_DIR=. shell
Makefile:130: The docker client CLI has moved to github.com/docker/cli. For a dev-test cycle involving the CLI, run:
 DOCKER_CLI_PATH=/host/path/to/cli/binary make shell 
 then change the cli and compile into a binary at the same location.

docker build   --target=dev -t "docker-dev:farnasirim-36413-bind-dir-skip-copy" -f "Dockerfile" .
Sending build context to Docker daemon  323.6MB
Step 1/92 : FROM golang:1.11.2 AS base
 ---> df6ac9d1bf64
Step 2/92 : ARG APT_MIRROR=deb.debian.org
 ---> Using cache
 ---> 12f851b643c8
Step 3/92 : RUN sed -ri "s/(httpredir|deb).debian.org/$APT_MIRROR/g" /etc/apt/sources.list
 ---> Using cache
 ---> af06af483151
Step 4/92 : FROM base AS criu
 ---> af06af483151
Step 5/92 : ENV CRIU_VERSION 3.6
 ---> Using cache
 ---> 6ee642897f5f
Step 6/92 : RUN apt-get update && apt-get install -y 	libnet-dev 	libprotobuf-c0-dev 	libprotobuf-dev 	libnl-3-dev 	libcap-dev 	protobuf-compiler 	protobuf-c-compiler 	python-protobuf 	&& mkdir -p /usr/src/criu 	&& curl -sSL https://github.com/checkpoint-restore/criu/archive/v${CRIU_VERSION}.tar.gz | tar -C /usr/src/criu/ -xz --strip-components=1 	&& cd /usr/src/criu 	&& make 	&& make PREFIX=/build/ install-criu
 ---> Using cache
 ---> 10fc2984cced
Step 7/92 : FROM base AS registry
 ---> af06af483151
Step 8/92 : ENV REGISTRY_COMMIT_SCHEMA1 ec87e9b6971d831f0eff752ddb54fb64693e51cd
 ---> Using cache
 ---> fcc31578dd6a
Step 9/92 : ENV REGISTRY_COMMIT 47a064d4195a9b56133891bbb13620c3ac83a827
 ---> Using cache
 ---> 36e322512256
Step 10/92 : RUN set -x 	&& export GOPATH="$(mktemp -d)" 	&& git clone https://github.com/docker/distribution.git "$GOPATH/src/github.com/docker/distribution" 	&& (cd "$GOPATH/src/github.com/docker/distribution" && git checkout -q "$REGISTRY_COMMIT") 	&& GOPATH="$GOPATH/src/github.com/docker/distribution/Godeps/_workspace:$GOPATH" 		go build -buildmode=pie -o /build/registry-v2 github.com/docker/distribution/cmd/registry 	&& case $(dpkg --print-architecture) in 		amd64|ppc64*|s390x) 		(cd "$GOPATH/src/github.com/docker/distribution" && git checkout -q "$REGISTRY_COMMIT_SCHEMA1"); 		GOPATH="$GOPATH/src/github.com/docker/distribution/Godeps/_workspace:$GOPATH"; 			go build -buildmode=pie -o /build/registry-v2-schema1 github.com/docker/distribution/cmd/registry; 		;; 	   esac 	&& rm -rf "$GOPATH"
 ---> Using cache
 ---> 7d018952913d
Step 11/92 : FROM base AS docker-py
 ---> af06af483151
Step 12/92 : ENV DOCKER_PY_COMMIT 8b246db271a85d6541dc458838627e89c683e42f
 ---> Using cache
 ---> d2589b543f6b
Step 13/92 : RUN git clone https://github.com/docker/docker-py.git /build 	&& cd /build 	&& git checkout -q $DOCKER_PY_COMMIT
 ---> Using cache
 ---> 6552d7add27d
Step 14/92 : FROM base AS swagger
 ---> af06af483151
Step 15/92 : ENV GO_SWAGGER_COMMIT c28258affb0b6251755d92489ef685af8d4ff3eb
 ---> Using cache
 ---> e8df2de1d3e2
Step 16/92 : RUN set -x 	&& export GOPATH="$(mktemp -d)" 	&& git clone https://github.com/go-swagger/go-swagger.git "$GOPATH/src/github.com/go-swagger/go-swagger" 	&& (cd "$GOPATH/src/github.com/go-swagger/go-swagger" && git checkout -q "$GO_SWAGGER_COMMIT") 	&& go build -o /build/swagger github.com/go-swagger/go-swagger/cmd/swagger 	&& rm -rf "$GOPATH"
 ---> Using cache
 ---> d023566008fc
Step 17/92 : FROM base AS frozen-images
 ---> af06af483151
Step 18/92 : RUN apt-get update && apt-get install -y jq ca-certificates --no-install-recommends
 ---> Using cache
 ---> bae00cf532a8
Step 19/92 : COPY contrib/download-frozen-image-v2.sh /
 ---> Using cache
 ---> 328e20c3ff2f
Step 20/92 : RUN /download-frozen-image-v2.sh /build 	buildpack-deps:jessie@sha256:dd86dced7c9cd2a724e779730f0a53f93b7ef42228d4344b25ce9a42a1486251 	busybox:latest@sha256:bbc3a03235220b170ba48a157dd097dd1379299370e1ed99ce976df0355d24f0 	busybox:glibc@sha256:0b55a30394294ab23b9afd58fab94e61a923f5834fba7ddbae7f8e0c11ba85e6 	debian:jessie@sha256:287a20c5f73087ab406e6b364833e3fb7b3ae63ca0eb3486555dc27ed32c6e60 	hello-world:latest@sha256:be0cd392e45be79ffeffa6b05338b98ebb16c87b255f48e297ec7f98e123905c
 ---> Using cache
 ---> e257af0e8de3
Step 21/92 : FROM base AS runtime-dev
 ---> af06af483151
Step 22/92 : RUN apt-get update && apt-get install -y 	libapparmor-dev 	libseccomp-dev
 ---> Using cache
 ---> 0147e85a450d
Step 23/92 : FROM base AS tomlv
 ---> af06af483151
Step 24/92 : ENV INSTALL_BINARY_NAME=tomlv
 ---> Using cache
 ---> f68198db7623
Step 25/92 : COPY hack/dockerfile/install/install.sh ./install.sh
 ---> Using cache
 ---> a7f128198a08
Step 26/92 : COPY hack/dockerfile/install/$INSTALL_BINARY_NAME.installer ./
 ---> Using cache
 ---> 1950308ba224
Step 27/92 : RUN PREFIX=/build/ ./install.sh $INSTALL_BINARY_NAME
 ---> Using cache
 ---> f82879e70a22
Step 28/92 : FROM base AS vndr
 ---> af06af483151
Step 29/92 : ENV INSTALL_BINARY_NAME=vndr
 ---> Using cache
 ---> ea268a435f08
Step 30/92 : COPY hack/dockerfile/install/install.sh ./install.sh
 ---> Using cache
 ---> 551eb4a6263b
Step 31/92 : COPY hack/dockerfile/install/$INSTALL_BINARY_NAME.installer ./
 ---> Using cache
 ---> 81e52253aff9
Step 32/92 : RUN PREFIX=/build/ ./install.sh $INSTALL_BINARY_NAME
 ---> Using cache
 ---> 265c23995467
Step 33/92 : FROM base AS containerd
 ---> af06af483151
Step 34/92 : RUN apt-get update && apt-get install -y btrfs-tools
 ---> Using cache
 ---> 6bb75e9d6291
Step 35/92 : ENV INSTALL_BINARY_NAME=containerd
 ---> Using cache
 ---> c7f5cb778990
Step 36/92 : COPY hack/dockerfile/install/install.sh ./install.sh
 ---> Using cache
 ---> 63cbd7d92880
Step 37/92 : COPY hack/dockerfile/install/$INSTALL_BINARY_NAME.installer ./
 ---> Using cache
 ---> df4ade0a754b
Step 38/92 : RUN PREFIX=/build/ ./install.sh $INSTALL_BINARY_NAME
 ---> Using cache
 ---> 2c821ea41e0a
Step 39/92 : FROM base AS proxy
 ---> af06af483151
Step 40/92 : ENV INSTALL_BINARY_NAME=proxy
 ---> Using cache
 ---> 8454576de3b5
Step 41/92 : COPY hack/dockerfile/install/install.sh ./install.sh
 ---> Using cache
 ---> b651473ca677
Step 42/92 : COPY hack/dockerfile/install/$INSTALL_BINARY_NAME.installer ./
 ---> Using cache
 ---> 481e35c7a9f2
Step 43/92 : RUN PREFIX=/build/ ./install.sh $INSTALL_BINARY_NAME
 ---> Using cache
 ---> 5ee12874e089
Step 44/92 : FROM base AS gometalinter
 ---> af06af483151
Step 45/92 : ENV INSTALL_BINARY_NAME=gometalinter
 ---> Using cache
 ---> 4e2c7964c63d
Step 46/92 : COPY hack/dockerfile/install/install.sh ./install.sh
 ---> Using cache
 ---> 7be5efd18ea1
Step 47/92 : COPY hack/dockerfile/install/$INSTALL_BINARY_NAME.installer ./
 ---> Using cache
 ---> e77f84b1d773
Step 48/92 : RUN PREFIX=/build/ ./install.sh $INSTALL_BINARY_NAME
 ---> Using cache
 ---> 980d0883c650
Step 49/92 : FROM base AS dockercli
 ---> af06af483151
Step 50/92 : ENV INSTALL_BINARY_NAME=dockercli
 ---> Using cache
 ---> 07e400140d76
Step 51/92 : COPY hack/dockerfile/install/install.sh ./install.sh
 ---> Using cache
 ---> ec3f0a6d68ad
Step 52/92 : COPY hack/dockerfile/install/$INSTALL_BINARY_NAME.installer ./
 ---> Using cache
 ---> addeb63ac0f7
Step 53/92 : RUN PREFIX=/build/ ./install.sh $INSTALL_BINARY_NAME
 ---> Using cache
 ---> 3149c515b93f
Step 54/92 : FROM runtime-dev AS runc
 ---> 0147e85a450d
Step 55/92 : ENV INSTALL_BINARY_NAME=runc
 ---> Using cache
 ---> 4fcbd79b12ee
Step 56/92 : COPY hack/dockerfile/install/install.sh ./install.sh
 ---> Using cache
 ---> d5ab60263ca8
Step 57/92 : COPY hack/dockerfile/install/$INSTALL_BINARY_NAME.installer ./
 ---> Using cache
 ---> 1aa29e6b5b5d
Step 58/92 : RUN PREFIX=/build/ ./install.sh $INSTALL_BINARY_NAME
 ---> Using cache
 ---> 26a50411e62a
Step 59/92 : FROM base AS tini
 ---> af06af483151
Step 60/92 : RUN apt-get update && apt-get install -y cmake vim-common
 ---> Using cache
 ---> 85107c987335
Step 61/92 : COPY hack/dockerfile/install/install.sh ./install.sh
 ---> Using cache
 ---> 8646645d2611
Step 62/92 : ENV INSTALL_BINARY_NAME=tini
 ---> Using cache
 ---> 444610d5a030
Step 63/92 : COPY hack/dockerfile/install/$INSTALL_BINARY_NAME.installer ./
 ---> Using cache
 ---> 8880a4e3d97b
Step 64/92 : RUN PREFIX=/build/ ./install.sh $INSTALL_BINARY_NAME
 ---> Using cache
 ---> ffe02b25eba5
Step 65/92 : FROM runtime-dev AS dev
 ---> 0147e85a450d
Step 66/92 : RUN groupadd -r docker
 ---> Using cache
 ---> f37e0e38d165
Step 67/92 : RUN useradd --create-home --gid docker unprivilegeduser
 ---> Using cache
 ---> bb649793ea04
Step 68/92 : RUN ln -sfv /go/src/github.com/docker/docker/.bashrc ~/.bashrc
 ---> Using cache
 ---> 36e1ed44b117
Step 69/92 : RUN echo "source /usr/share/bash-completion/bash_completion" >> /etc/bash.bashrc
 ---> Using cache
 ---> c2a7c22737a9
Step 70/92 : RUN ln -s /usr/local/completion/bash/docker /etc/bash_completion.d/docker
 ---> Using cache
 ---> a60a1ff5c42d
Step 71/92 : RUN ldconfig
 ---> Using cache
 ---> 00289b232485
Step 72/92 : RUN apt-get update && apt-get install -y 	apparmor 	aufs-tools 	bash-completion 	btrfs-tools 	iptables 	jq 	libcap2-bin 	libdevmapper-dev 	libudev-dev 	libsystemd-dev 	binutils-mingw-w64 	g++-mingw-w64-x86-64 	net-tools 	pigz 	python-backports.ssl-match-hostname 	python-dev 	python-mock 	python-pip 	python-requests 	python-setuptools 	python-websocket 	python-wheel 	thin-provisioning-tools 	vim 	vim-common 	xfsprogs 	zip 	bzip2 	xz-utils 	--no-install-recommends
 ---> Using cache
 ---> ac0d8aee1408
Step 73/92 : COPY --from=swagger /build/swagger* /usr/local/bin/
 ---> Using cache
 ---> 2f358ad60fcc
Step 74/92 : COPY --from=frozen-images /build/ /docker-frozen-images
 ---> Using cache
 ---> 3db81a217aa5
Step 75/92 : COPY --from=gometalinter /build/ /usr/local/bin/
 ---> Using cache
 ---> 366ea8707971
Step 76/92 : COPY --from=tomlv /build/ /usr/local/bin/
 ---> Using cache
 ---> 622aa7d7ebc4
Step 77/92 : COPY --from=vndr /build/ /usr/local/bin/
 ---> Using cache
 ---> 285ad5e4a36a
Step 78/92 : COPY --from=tini /build/ /usr/local/bin/
 ---> Using cache
 ---> c1774993310c
Step 79/92 : COPY --from=runc /build/ /usr/local/bin/
 ---> Using cache
 ---> 1fa35a5f346e
Step 80/92 : COPY --from=containerd /build/ /usr/local/bin/
 ---> Using cache
 ---> c7f4ddabe1be
Step 81/92 : COPY --from=proxy /build/ /usr/local/bin/
 ---> Using cache
 ---> 9a2aee40c9d0
Step 82/92 : COPY --from=dockercli /build/ /usr/local/cli
 ---> Using cache
 ---> 49bdd5e3e85e
Step 83/92 : COPY --from=registry /build/registry* /usr/local/bin/
 ---> Using cache
 ---> 3702fe769414
Step 84/92 : COPY --from=criu /build/ /usr/local/
 ---> Using cache
 ---> fd60d4f41204
Step 85/92 : COPY --from=docker-py /build/ /docker-py
 ---> Using cache
 ---> 3ec2ea91f66f
Step 86/92 : RUN cd /docker-py 	&& pip install docker-pycreds==0.2.1 	&& pip install yamllint==1.5.0 	&& pip install -r test-requirements.txt
 ---> Using cache
 ---> 0d2d6fb4217c
Step 87/92 : ENV PATH=/usr/local/cli:$PATH
 ---> Using cache
 ---> aa92ae7af1fd
Step 88/92 : ENV DOCKER_BUILDTAGS apparmor seccomp selinux
 ---> Using cache
 ---> 5ca39266329b
Step 89/92 : ENV GOMETALINTER_OPTS="--deadline=2m"
 ---> Using cache
 ---> 1860d62204cf
Step 90/92 : WORKDIR /go/src/github.com/docker/docker
 ---> Using cache
 ---> d0d600347692
Step 91/92 : VOLUME /var/lib/docker
 ---> Using cache
 ---> 1bc3adb1e38b
Step 92/92 : ENTRYPOINT ["hack/dind"]
 ---> Using cache
 ---> c3ea1fd351fb
Successfully built c3ea1fd351fb
Successfully tagged docker-dev:farnasirim-36413-bind-dir-skip-copy
docker run --rm -i --privileged  -e DOCKER_CROSSPLATFORMS -e BUILD_APT_MIRROR -e BUILDFLAGS -e KEEPBUNDLE -e DOCKER_BUILD_ARGS -e DOCKER_BUILD_GOGC -e DOCKER_BUILD_OPTS -e DOCKER_BUILD_PKGS -e DOCKER_BUILDKIT -e DOCKER_BASH_COMPLETION_PATH -e DOCKER_CLI_PATH -e DOCKER_DEBUG -e DOCKER_EXPERIMENTAL -e DOCKER_GITCOMMIT -e DOCKER_GRAPHDRIVER -e DOCKER_LDFLAGS -e DOCKER_PORT -e DOCKER_REMAP_ROOT -e DOCKER_STORAGE_OPTS -e DOCKER_USERLANDPROXY -e DOCKERD_ARGS -e TEST_INTEGRATION_DIR -e TESTDIRS -e TESTFLAGS -e TIMEOUT -e HTTP_PROXY -e HTTPS_PROXY -e NO_PROXY -e http_proxy -e https_proxy -e no_proxy -e VERSION -e PLATFORM -e DEFAULT_PRODUCT_LICENSE -e PRODUCT -v "/Users/sebastiaan/go/src/github.com/docker/docker/.:/go/src/github.com/docker/docker/." -v "/Users/sebastiaan/go/src/github.com/docker/docker/.git:/go/src/github.com/docker/docker/.git" -v docker-dev-cache:/root/.cache    -t "docker-dev:farnasirim-36413-bind-dir-skip-copy" bash
root@245a51d98b1a:/go/src/github.com/docker/docker# 

@codecov
Copy link
Copy Markdown

codecov bot commented Dec 22, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@5ddb1d4). Click here to learn what that means.
The diff coverage is n/a.

@@            Coverage Diff            @@
##             master   #38370   +/-   ##
=========================================
  Coverage          ?   36.54%           
=========================================
  Files             ?      608           
  Lines             ?    45040           
  Branches          ?        0           
=========================================
  Hits              ?    16458           
  Misses            ?    26300           
  Partials          ?     2282

@farnasirim farnasirim force-pushed the 36413-bind-dir-skip-copy branch 3 times, most recently from 100c93c to 52a1aa6 Compare December 22, 2018 18:54
@farnasirim
Copy link
Copy Markdown
Contributor Author

@thaJeztah Oh sorry I was just notified of this.
Yes that's indeed a much nicer way of doing it.
Updated the PR.
Btw any suggestions on what I can work on next?

Copy link
Copy Markdown
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

found two minor issues; can you address those? otherwise looks good (thanks!)

Makefile Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops; you forgot to remove this line

Makefile Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line uses spaces for indentation; can you change to tabs to be consistent with the other lines?

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>
@farnasirim farnasirim force-pushed the 36413-bind-dir-skip-copy branch from 52a1aa6 to e6d7df2 Compare December 27, 2018 04:00
@farnasirim
Copy link
Copy Markdown
Contributor Author

@thaJeztah Whoops, My bad. I applied the patch incorrectly leading to a few issues. Whitespace etc.
Should be good now.

Copy link
Copy Markdown
Contributor

@fntlnz fntlnz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎅

Copy link
Copy Markdown
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dockerfile: skip COPY if BIND_DIR is used

4 participants