|
| 1 | +# set all to phony |
| 2 | +SHELL=bash |
| 3 | + |
| 4 | +.PHONY: * |
| 5 | + |
| 6 | +mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) |
| 7 | +current_dir := $(abspath $(patsubst %/,%,$(dir $(mkfile_path)))) |
| 8 | + |
| 9 | +THREADS := $(shell docker info -f '{{ .NCPU }}') |
| 10 | + |
| 11 | +export DOCKER_BUILDKIT=1 |
| 12 | +export COMPOSE_DOCKER_CLI_BUILD=1 |
| 13 | +export LOCAL_COMPOSER_HOME=$(shell composer config --global home 2> /dev/null || echo ${HOME}/.config/composer) |
| 14 | +export LOCAL_COMPOSER_CACHE_DIR=$(shell composer config --global cache-dir 2> /dev/null || echo ${HOME}/.config/composer/cache) |
| 15 | + |
| 16 | +DOCKER_RUN=@docker run -it --rm \ |
| 17 | + --volume=$(shell pwd):/opt/project \ |
| 18 | + amsphp-console-cli |
| 19 | + |
| 20 | +DOCKER_RUN_COMPOSER=@docker run -it --rm \ |
| 21 | + --volume=${LOCAL_COMPOSER_CACHE_DIR}:/tmp/composer/cache \ |
| 22 | + --volume=${LOCAL_COMPOSER_HOME}:/.config/composer \ |
| 23 | + --volume=$(shell pwd):/opt/project \ |
| 24 | + amsphp-console-cli |
| 25 | + |
| 26 | +DOCKER_RUN_TEST=@docker run -it --rm \ |
| 27 | + --volume=$(shell pwd):/opt/project \ |
| 28 | + amsphp-console-cli |
| 29 | + |
| 30 | +DOCKER_RUN_XDEBUG_COVERAGE=@XDEBUG_MODE=coverage docker run -it --rm \ |
| 31 | + --volume=$(shell pwd):/opt/project \ |
| 32 | + amsphp-console-cli |
| 33 | + |
| 34 | +all: build composer-install test |
| 35 | + |
| 36 | +install: env-check docker-lint docker-build composer-install ## Builds the project |
| 37 | + |
| 38 | +build: |
| 39 | + @echo -e "\033[33mBuilding PHP docker images\033[0m" |
| 40 | + @docker build -f docker/cli.Dockerfile -t amsphp-console-cli . |
| 41 | + |
| 42 | +composer-install: ## Install dependencies with composer, according to the existing composer.lock |
| 43 | + @echo -e "\033[33mInstalling dependencies\033[0m" |
| 44 | + $(DOCKER_RUN_COMPOSER) composer install -n -o |
| 45 | + |
| 46 | +composer-require-checker: env-check ## Checks if all root dependencies are declared |
| 47 | + @echo -e "\033[33mChecking composer requirements\033[0m" |
| 48 | + $(DOCKER_RUN_COMPOSER) vendor/bin/composer-require-checker check --config-file=composer-require-checker.json |
| 49 | + |
| 50 | +composer-validate: env-check ## Runs composer validate |
| 51 | + @echo -e "\033[33mValidating composer.json\033[0m" |
| 52 | + $(DOCKER_RUN_COMPOSER) composer validate --no-check-all --strict |
| 53 | + |
| 54 | +test: |
| 55 | + @echo -e "\033[33mRunning Tests\033[0m" |
| 56 | + $(DOCKER_RUN_TEST) ./vendor/bin/phpunit |
| 57 | + |
| 58 | +run-cmd: |
| 59 | + $(DOCKER_RUN) bin/console $(ARGS) |
| 60 | + |
| 61 | +shell: ## Gives shell access inside the container |
| 62 | + $(DOCKER_RUN) sh |
| 63 | + |
| 64 | +help: |
| 65 | + @echo "\033[33mUsage:\033[0m\n make [target] [FLAGS=\"val\"...]\n\n\033[33mTargets:\033[0m" |
| 66 | + @grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[32m%-18s\033[0m %s\n", $$1, $$2}' |
0 commit comments