From c1f0bee31cc44c655f8d5aab8133e489ded12e89 Mon Sep 17 00:00:00 2001 From: Gaetan de Villele Date: Tue, 9 May 2017 14:29:14 -0700 Subject: [PATCH] =?UTF-8?q?update=20makefiles:=20add=20=E2=80=9Cvendor?= =?UTF-8?q?=E2=80=9D=20target=20in=20docker.Makefile=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … so that contributors don’t need “vndr” on their laptop Signed-off-by: Gaetan de Villele --- Makefile | 9 +++++++-- docker.Makefile | 17 ++++++++++++++--- vendor.conf | 1 - 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index d1f0c73e00..3552e49a2a 100644 --- a/Makefile +++ b/Makefile @@ -2,31 +2,36 @@ # github.com/docker/cli # -.PHONY: build clean test lint cross - # build the CLI +.PHONY: build build: clean @go build -o ./build/docker github.com/docker/cli/cmd/docker # remove build artifacts +.PHONY: clean clean: @rm -rf ./build/* # run go test # the "-tags daemon" part is temporary +.PHONY: test test: @go test -tags daemon -v $(shell go list ./... | grep -v /vendor/) # run linters +.PHONY: lint lint: @gometalinter --config gometalinter.json ./... # build the CLI for multiple architectures +.PHONY: cross cross: clean @gox -output build/docker-{{.OS}}-{{.Arch}} \ -osarch="linux/arm linux/amd64 darwin/amd64 windows/amd64" \ github.com/docker/cli/cmd/docker +# download dependencies (vendor/) listed in vendor.conf +.PHONY: vendor vendor: vendor.conf @vndr 2> /dev/null @if [ "`git status --porcelain -- vendor 2>/dev/null`" ]; then \ diff --git a/docker.Makefile b/docker.Makefile index c2f9ff5626..e9128f3b8a 100644 --- a/docker.Makefile +++ b/docker.Makefile @@ -4,41 +4,52 @@ # Makefile for developing using Docker # -+.PHONY: build_docker_image build_linter_image build clean test cross dev lint - DEV_DOCKER_IMAGE_NAME = docker-cli-dev LINTER_IMAGE_NAME = docker-cli-lint MOUNTS = -v `pwd`:/go/src/github.com/docker/cli # build docker image (dockerfiles/Dockerfile.build) +.PHONY: build_docker_image build_docker_image: @docker build -q -t $(DEV_DOCKER_IMAGE_NAME) -f ./dockerfiles/Dockerfile.build . -.PHONY: builder_linter_image +# build docker image having the linting tools (dockerfiles/Dockerfile.lint) +.PHONY: build_linter_image build_linter_image: @docker build -q -t $(LINTER_IMAGE_NAME) -f ./dockerfiles/Dockerfile.lint . # build executable using a container +.PHONY: build build: build_docker_image @echo "WARNING: this will drop a Linux executable on your host (not a macOS of Windows one)" @docker run --rm $(MOUNTS) $(DEV_DOCKER_IMAGE_NAME) make build # clean build artifacts using a container +.PHONY: clean clean: build_docker_image @docker run --rm $(MOUNTS) $(DEV_DOCKER_IMAGE_NAME) make clean # run go test +.PHONY: test test: build_docker_image @docker run --rm $(MOUNTS) $(DEV_DOCKER_IMAGE_NAME) make test # build the CLI for multiple architectures using a container +.PHONY: cross cross: build_docker_image @docker run --rm $(MOUNTS) $(DEV_DOCKER_IMAGE_NAME) make cross # start container in interactive mode for in-container development +.PHONY: dev dev: build_docker_image @docker run -ti $(MOUNTS) -v /var/run/docker.sock:/var/run/docker.sock $(DEV_DOCKER_IMAGE_NAME) ash # run linters in a container +.PHONY: lint lint: build_linter_image @docker run -ti $(MOUNTS) $(LINTER_IMAGE_NAME) + +# download dependencies (vendor/) listed in vendor.conf, using a container +.PHONY: vendor +vendor: build_docker_image vendor.conf + @docker run -ti --rm $(MOUNTS) $(DEV_DOCKER_IMAGE_NAME) make vendor diff --git a/vendor.conf b/vendor.conf index 1d4e94439d..ddba886994 100644 --- a/vendor.conf +++ b/vendor.conf @@ -43,4 +43,3 @@ golang.org/x/text f72d8390a633d5dfb0cc84043294db9f6c935756 golang.org/x/time a4bde12657593d5e90d0533a3e4fd95e635124cb google.golang.org/grpc v1.0.4 gopkg.in/yaml.v2 4c78c975fe7c825c6d1466c42be594d1d6f3aba6 -