2017-04-25 12:57:06 -04:00
|
|
|
#
|
|
|
|
# github.com/docker/cli
|
|
|
|
#
|
|
|
|
# Makefile for developing using Docker
|
|
|
|
#
|
|
|
|
|
2017-05-02 15:10:03 -04:00
|
|
|
DEV_DOCKER_IMAGE_NAME = docker-cli-dev
|
|
|
|
LINTER_IMAGE_NAME = docker-cli-lint
|
|
|
|
MOUNTS = -v `pwd`:/go/src/github.com/docker/cli
|
2017-04-25 12:57:06 -04:00
|
|
|
|
|
|
|
# build docker image (dockerfiles/Dockerfile.build)
|
2017-05-09 17:29:14 -04:00
|
|
|
.PHONY: build_docker_image
|
2017-04-25 12:57:06 -04:00
|
|
|
build_docker_image:
|
2017-04-27 17:55:05 -04:00
|
|
|
@docker build -q -t $(DEV_DOCKER_IMAGE_NAME) -f ./dockerfiles/Dockerfile.build .
|
2017-04-25 12:57:06 -04:00
|
|
|
|
2017-05-09 17:29:14 -04:00
|
|
|
# build docker image having the linting tools (dockerfiles/Dockerfile.lint)
|
|
|
|
.PHONY: build_linter_image
|
2017-05-02 15:10:03 -04:00
|
|
|
build_linter_image:
|
|
|
|
@docker build -q -t $(LINTER_IMAGE_NAME) -f ./dockerfiles/Dockerfile.lint .
|
|
|
|
|
2017-04-25 12:57:06 -04:00
|
|
|
# build executable using a container
|
2017-05-09 17:29:14 -04:00
|
|
|
.PHONY: build
|
2017-04-25 12:57:06 -04:00
|
|
|
build: build_docker_image
|
2017-05-11 05:02:13 -04:00
|
|
|
@echo "WARNING: this will drop a Linux executable on your host (not a macOS or Windows one)"
|
2017-05-02 15:10:03 -04:00
|
|
|
@docker run --rm $(MOUNTS) $(DEV_DOCKER_IMAGE_NAME) make build
|
2017-04-25 12:57:06 -04:00
|
|
|
|
|
|
|
# clean build artifacts using a container
|
2017-05-09 17:29:14 -04:00
|
|
|
.PHONY: clean
|
2017-04-25 12:57:06 -04:00
|
|
|
clean: build_docker_image
|
2017-05-02 15:10:03 -04:00
|
|
|
@docker run --rm $(MOUNTS) $(DEV_DOCKER_IMAGE_NAME) make clean
|
2017-04-25 12:57:06 -04:00
|
|
|
|
2017-04-27 18:57:35 -04:00
|
|
|
# run go test
|
2017-05-09 17:29:14 -04:00
|
|
|
.PHONY: test
|
2017-04-27 18:57:35 -04:00
|
|
|
test: build_docker_image
|
2017-05-02 15:10:03 -04:00
|
|
|
@docker run --rm $(MOUNTS) $(DEV_DOCKER_IMAGE_NAME) make test
|
2017-04-27 18:57:35 -04:00
|
|
|
|
2017-04-25 12:57:06 -04:00
|
|
|
# build the CLI for multiple architectures using a container
|
2017-05-09 17:29:14 -04:00
|
|
|
.PHONY: cross
|
2017-04-25 12:57:06 -04:00
|
|
|
cross: build_docker_image
|
2017-05-02 15:10:03 -04:00
|
|
|
@docker run --rm $(MOUNTS) $(DEV_DOCKER_IMAGE_NAME) make cross
|
2017-04-25 12:57:06 -04:00
|
|
|
|
|
|
|
# start container in interactive mode for in-container development
|
2017-05-09 17:29:14 -04:00
|
|
|
.PHONY: dev
|
2017-04-25 12:57:06 -04:00
|
|
|
dev: build_docker_image
|
2017-05-03 14:14:06 -04:00
|
|
|
@docker run -ti $(MOUNTS) -v /var/run/docker.sock:/var/run/docker.sock $(DEV_DOCKER_IMAGE_NAME) ash
|
2017-05-02 15:10:03 -04:00
|
|
|
|
2017-05-03 14:14:06 -04:00
|
|
|
# run linters in a container
|
2017-05-09 17:29:14 -04:00
|
|
|
.PHONY: lint
|
2017-05-02 15:10:03 -04:00
|
|
|
lint: build_linter_image
|
|
|
|
@docker run -ti $(MOUNTS) $(LINTER_IMAGE_NAME)
|
2017-05-09 17:29:14 -04:00
|
|
|
|
|
|
|
# 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
|