Makefile 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. # Copyright 2020 The 2020 Docker, Inc.
  2. # Licensed under the Apache License, Version 2.0 (the "License");
  3. # you may not use this file except in compliance with the License.
  4. # You may obtain a copy of the License at
  5. # http://www.apache.org/licenses/LICENSE-2.0
  6. # Unless required by applicable law or agreed to in writing, software
  7. # distributed under the License is distributed on an "AS IS" BASIS,
  8. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. # See the License for the specific language governing permissions and
  10. # limitations under the License.
  11. export DOCKER_BUILDKIT=1
  12. UNAME_S := $(shell uname -s)
  13. ifeq ($(UNAME_S),Linux)
  14. MOBY_DOCKER=/usr/bin/docker
  15. endif
  16. ifeq ($(UNAME_S),Darwin)
  17. MOBY_DOCKER=/Applications/Docker.app/Contents/Resources/bin/docker
  18. endif
  19. GIT_TAG?=$(shell git describe --tags --match "v[0-9]*")
  20. TESTIFY_OPTS=$(if $(TESTIFY),-testify.m $(TESTIFY),)
  21. all: cli
  22. protos: ## Generate go code from .proto files
  23. @docker build . --target protos \
  24. --output ./protos
  25. cli: ## Compile the cli
  26. @docker build . --target cli \
  27. --platform local \
  28. --build-arg BUILD_TAGS=example,local \
  29. --build-arg GIT_TAG=$(GIT_TAG) \
  30. --output ./bin
  31. e2e-local: ## Run End to end local tests. set env TESTIFY=Test1 for running single test
  32. go test -v ./tests/e2e ./tests/skip-win-ci-e2e ./local/e2e $(TESTIFY_OPTS)
  33. e2e-win-ci: ## Run End to end local tests on windows CI, no docker for linux containers available ATM. set env TESTIFY=Test1 for running single test
  34. go test -v ./tests/e2e $(TESTIFY_OPTS)
  35. e2e-aci: ## Run End to end ACI tests. set env TESTIFY=Test1 for running single test
  36. go test -v ./tests/aci-e2e $(TESTIFY_OPTS)
  37. cross: ## Compile the CLI for linux, darwin and windows
  38. @docker build . --target cross \
  39. --build-arg BUILD_TAGS \
  40. --build-arg GIT_TAG=$(GIT_TAG) \
  41. --output ./bin \
  42. test: ## Run unit tests
  43. @docker build . \
  44. --build-arg BUILD_TAGS=example,local \
  45. --build-arg GIT_TAG=$(GIT_TAG) \
  46. --target test
  47. cache-clear: ## Clear the builder cache
  48. @docker builder prune --force --filter type=exec.cachemount --filter=unused-for=24h
  49. lint: ## run linter(s)
  50. @docker build . \
  51. --build-arg GIT_TAG=$(GIT_TAG) \
  52. --target lint
  53. serve: cli ## start server
  54. @./bin/docker serve --address unix:///tmp/backend.sock
  55. moby-cli-link: ## create com.docker.cli symlink if does not already exist
  56. ln -s $(MOBY_DOCKER) /usr/local/bin/com.docker.cli
  57. help: ## Show help
  58. @echo Please specify a build target. The choices are:
  59. @grep -E '^[0-9a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
  60. FORCE:
  61. .PHONY: all protos cli e2e-local cross test cache-clear lint serve classic-link help