-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
64 lines (53 loc) · 2.57 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
.PHONY: help
# https://gist.github.com/rsperl/d2dfe88a520968fbc1f49db0a29345b9
# define standard colors
BLACK := $(shell tput -Txterm setaf 0)
RED := $(shell tput -Txterm setaf 1)
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
LIGHTPURPLE := $(shell tput -Txterm setaf 4)
PURPLE := $(shell tput -Txterm setaf 5)
BLUE := $(shell tput -Txterm setaf 6)
WHITE := $(shell tput -Txterm setaf 7)
RESET := $(shell tput -Txterm sgr0)
docker_image = webdevops/php:8.1-alpine
docker_dev_image = webdevops/php-dev:8.1-alpine
help:
@echo 'This is a PHP 8.1 application.'
@echo 'If you have it (and ${WHITE}composer${RESET}) installed locally, then simply run:'
@echo ' ${GREEN}composer install${RESET}'
@echo ' ${GREEN}composer run tests${RESET}'
@echo ''
@echo 'This Makefile has some options to run the application in ${WHITE}docker${RESET} if you do not have 8.1 locally.'
@echo 'The ${WHITE}docker${RESET} image is ${LIGHTPURPLE}${docker_image}${RESET}'
@echo ''
@echo '${WHITE}----------------------------------------${RESET}'
@echo ''
@echo 'Usage: make [${BLUE}subcommand${RESET}]'
@echo 'subcommands:'
@echo ' ${GREEN}shell${RESET} Mounts current ${WHITE}pwd${RESET} and starts ${WHITE}sh${RESET} session in a ${WHITE}docker${RESET} image'
@echo ' ${GREEN}test${RESET} Mounts current ${WHITE}pwd${RESET} and runs ${WHITE}composer run tests${RESET} in a ${WHITE}docker${RESET} image'
@echo ' ${GREEN}phplint${RESET} Mounts current ${WHITE}pwd${RESET} and runs ${WHITE}composer run phplint${RESET} in a ${WHITE}docker${RESET} image'
@echo ' ${GREEN}phpcs${RESET} Mounts current ${WHITE}pwd${RESET} and runs ${WHITE}composer run phpcs${RESET} in a ${WHITE}docker${RESET} image'
@echo ' ${GREEN}coverage${RESET} Mounts current ${WHITE}pwd${RESET} and runs ${WHITE}composer run coverage${RESET} in a ${WHITE}docker${RESET} image'
@echo ' ${YELLOW}NOTE: this uses an alternative image, ${LIGHTPURPLE}${docker_dev_image}${RESET}'
ephemeral_docker_args = --rm \
--tty \
--interactive \
--user=$(shell id -u):$(shell id -g)
docker_run = docker run \
${ephemeral_docker_args} \
--volume="$(shell pwd):/src" \
--workdir=/src
shell:
@${docker_run} ${docker_image} bash
install:
@${docker_run} ${docker_image} composer install
test:
@${docker_run} ${docker_image} composer run tests
phplint:
@${docker_run} ${docker_image} composer run phplint
phpcs:
@${docker_run} ${docker_image} composer run phpcs
coverage:
@${docker_run} --env XDEBUG_MODE=coverage ${docker_dev_image} composer run coverage