Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 7112751

Browse files
committed
Improve make -f docker.Makefile vendor
Initial work from @ijc brought a containerized vendoring which was great but had a few issues: - did not work on Windows: dependencies containing symlinks could not be written by golang/dep on a cifs-mounted volume (wich is the case when mounting a windows dir in Docker Desktop) - slow: 2 reasons for that: doing the vendoring accross a cifs or osxfs bind mount was far from ideal due to FS latency and caching issues. There was no cache preservation between 2 calls. This fix all those issues by: - Not using bind mounts: we resolve the vendoring directly in the container RootFS, then copy back the vendor dir and the Gopkg.lock file (which might have been updated) to the host - Mounting a volume in which golang/dep will keep repo info and git clones in cache Note that the dep-cache mount point and DEPCACHEDIR env var are //dep-cache and not /dep-cache. From a Unix FS point of view both paths are equivalent. But some windows shells (like the bash version shipped with Git on Windows) tries to do clever conversions to win32 paths when detecting unix-style paths in command line arguments, which makes docker trying to mount the volume in "c:\Program Files\Git\bin\..." which makes no sense in a Linux container. Doubling the initial "/" disable this behavior. Signed-off-by: Simon Ferquel <[email protected]>
1 parent 622f5d9 commit 7112751

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

docker.Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,13 @@ lint: ## run linter(s)
110110

111111
vendor: build_dev_image
112112
$(info Update Vendoring...)
113-
docker run --rm -v "$(CURDIR)":/go/src/github.com/docker/app/ $(DEV_IMAGE_NAME) make vendor
113+
rm -rf ./vendor
114+
docker rm -f docker-app-vendoring || echo ""
115+
docker create --name docker-app-vendoring -v docker-app-vendor-cache://dep-cache -e DEPCACHEDIR=//dep-cache $(DEV_IMAGE_NAME) sh -c "rm -rf ./vendor && make vendor"
116+
docker start -i -a docker-app-vendoring
117+
docker cp docker-app-vendoring:/go/src/github.com/docker/app/vendor .
118+
docker cp docker-app-vendoring:/go/src/github.com/docker/app/Gopkg.lock .
119+
docker rm -f docker-app-vendoring
114120
$(warning You may need to reset permissions on vendor/*)
115121

116122
check-vendor: build_dev_image

0 commit comments

Comments
 (0)