Makefile 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. TAG = "docker-compose:alpine-$(shell git rev-parse --short HEAD)"
  2. GIT_VOLUME = "--volume=$(shell pwd)/.git:/code/.git"
  3. DOCKERFILE ?="Dockerfile"
  4. DOCKER_BUILD_TARGET ?="build"
  5. UNAME_S := $(shell uname -s)
  6. ifeq ($(UNAME_S),Linux)
  7. BUILD_SCRIPT = linux
  8. endif
  9. ifeq ($(UNAME_S),Darwin)
  10. BUILD_SCRIPT = osx
  11. endif
  12. COMPOSE_SPEC_SCHEMA_PATH = "compose/config/compose_spec.json"
  13. COMPOSE_SPEC_RAW_URL = "https://raw.githubusercontent.com/compose-spec/compose-spec/master/schema/compose-spec.json"
  14. all: cli
  15. cli: download-compose-spec ## Compile the cli
  16. ./script/build/$(BUILD_SCRIPT)
  17. download-compose-spec: ## Download the compose-spec schema from it's repo
  18. curl -so $(COMPOSE_SPEC_SCHEMA_PATH) $(COMPOSE_SPEC_RAW_URL)
  19. cache-clear: ## Clear the builder cache
  20. @docker builder prune --force --filter type=exec.cachemount --filter=unused-for=24h
  21. base-image: ## Builds base image
  22. docker build -f $(DOCKERFILE) -t $(TAG) --target $(DOCKER_BUILD_TARGET) .
  23. lint: base-image ## Run linter
  24. docker run --rm \
  25. --tty \
  26. $(GIT_VOLUME) \
  27. $(TAG) \
  28. tox -e pre-commit
  29. test-unit: base-image ## Run tests
  30. docker run --rm \
  31. --tty \
  32. $(GIT_VOLUME) \
  33. $(TAG) \
  34. pytest -v tests/unit/
  35. test: ## Run all tests
  36. ./script/test/default
  37. pre-commit: lint test-unit cli
  38. help: ## Show help
  39. @echo Please specify a build target. The choices are:
  40. @grep -E '^[0-9a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
  41. FORCE:
  42. .PHONY: all cli download-compose-spec cache-clear base-image lint test-unit test pre-commit help