Makefile 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. TEST_FLAGS?=
  21. E2E_TEST?=
  22. ifeq ($(E2E_TEST),)
  23. else
  24. TEST_FLAGS=-run $(E2E_TEST)
  25. endif
  26. all: cli
  27. protos: ## Generate go code from .proto files
  28. @docker build . --target protos \
  29. --output ./protos
  30. cli: ## Compile the cli
  31. @docker build . --target cli \
  32. --platform local \
  33. --build-arg BUILD_TAGS=example,local,ecs \
  34. --build-arg GIT_TAG=$(GIT_TAG) \
  35. --output ./bin
  36. e2e-local: ## Run End to end local tests. Set E2E_TEST=TestName to run a single test
  37. go test -count=1 -v $(TEST_FLAGS) ./tests/e2e ./tests/skip-win-ci-e2e ./local/e2e
  38. e2e-win-ci: ## Run end to end local tests on Windows CI, no Docker for Linux containers available ATM. Set E2E_TEST=TestName to run a single test
  39. go test -count=1 -v $(TEST_FLAGS) ./tests/e2e
  40. e2e-aci: ## Run End to end ACI tests. Set E2E_TEST=TestName to run a single test
  41. go test -count=1 -v $(TEST_FLAGS) ./tests/aci-e2e
  42. cross: ## Compile the CLI for linux, darwin and windows
  43. @docker build . --target cross \
  44. --build-arg BUILD_TAGS \
  45. --build-arg GIT_TAG=$(GIT_TAG) \
  46. --output ./bin \
  47. test: ## Run unit tests
  48. @docker build . \
  49. --build-arg BUILD_TAGS=example,local,ecs \
  50. --build-arg GIT_TAG=$(GIT_TAG) \
  51. --target test
  52. cache-clear: ## Clear the builder cache
  53. @docker builder prune --force --filter type=exec.cachemount --filter=unused-for=24h
  54. lint: ## run linter(s)
  55. @docker build . \
  56. --build-arg GIT_TAG=$(GIT_TAG) \
  57. --target lint
  58. serve: cli ## start server
  59. @./bin/docker serve --address unix:///tmp/backend.sock
  60. moby-cli-link: ## create com.docker.cli symlink if does not already exist
  61. ln -s $(MOBY_DOCKER) /usr/local/bin/com.docker.cli
  62. help: ## Show help
  63. @echo Please specify a build target. The choices are:
  64. @grep -E '^[0-9a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
  65. FORCE:
  66. .PHONY: all protos cli e2e-local cross test cache-clear lint serve classic-link help