forked from akeneo/demo-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
157 lines (130 loc) · 3.36 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
MAKEFLAGS += --no-print-directory
##
## Environment variables
##
ifneq (,$(wildcard ./.env))
DOTENV_PATH=/tmp/$(shell echo $$(pwd) | base64)
include $(shell cat .env | grep -v --perl-regexp '^('$$(env | sed 's/=.*//'g | tr '\n' '|')')\=' | sed 's/=/?=/g' > $(DOTENV_PATH); echo '$(DOTENV_PATH)')
endif
APP_ENV ?= dev
DOCKER_PORT_HTTP ?= 8080
DOCKER_BUILDKIT ?= 1
ifeq ($(APP_ENV), prod)
COMPOSER_ARGS += --no-dev
endif
# Binaries
DOCKER_COMPOSE = docker-compose
COMPOSER = $(DOCKER_COMPOSE) run --rm --no-deps app composer $(COMPOSER_ARGS)
PHP = $(DOCKER_COMPOSE) run --rm --no-deps app
YARN = $(DOCKER_COMPOSE) run --rm --no-deps app yarn
# Export all variables so they are accessible in the shells created by make
export
##
## Infra
##
include infra/terraform.mk
##
## Entrypoints
##
.PHONY: up
up:
$(MAKE) build
$(DOCKER_COMPOSE) up -d --remove-orphans
@echo "\e[30m\e[42m\n"
@echo " App is up and running at http://localhost:$(DOCKER_PORT_HTTP)"
@echo "\e[49m\e[39m\n"
.PHONY: build
build:
$(MAKE) .env
$(DOCKER_COMPOSE) build
$(MAKE) dependencies
$(MAKE) cache
$(PHP) bin/console assets:install public
$(YARN) build
.PHONY: down
down:
$(DOCKER_COMPOSE) down --remove-orphans
.PHONY: destroy
destroy:
$(DOCKER_COMPOSE) down --remove-orphans --volumes --rmi local
##
## Docker image for production
##
.PHONY: docker-image
docker-image: PHP_PCOV_ENABLED = 0
docker-image: PHP_XDEBUG_MODE = off
docker-image: DOCKER_IMAGE_VERSION ?= latest
docker-image:
docker build . \
--build-arg APP_ENV=prod \
--build-arg USER=www-data \
--target production \
-t $(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_VERSION)
.PHONY: docker-push
docker-push: DOCKER_IMAGE_VERSION ?= latest
docker-push:
docker push $(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_VERSION)
##
## Dependencies
##
.PHONY: dependencies
dependencies:
$(COMPOSER) install \
--no-interaction \
--no-ansi \
--prefer-dist \
--optimize-autoloader
$(YARN) install --frozen-lockfile
##
## Misc
##
.env:
cp -n .env.dist .env
.PHONY: cache
cache:
$(PHP) rm -rf var/cache
$(PHP) bin/console cache:warmup
.PHONY: cs-fix
cs-fix:
$(PHP) vendor/bin/php-cs-fixer fix
$(YARN) stylelint "assets/styles/**/*.scss" --fix
##
## Tests
##
.PHONY: tests
tests: APP_ENV=test
tests: PHP_PCOV_ENABLED=0
tests: PHP_XDEBUG_MODE=off
tests:
$(MAKE) cache
$(MAKE) tests-static
$(MAKE) tests-unit
$(MAKE) tests-integration
.PHONY: tests-static
tests-static:
$(PHP) vendor/bin/php-cs-fixer fix --dry-run --diff
$(PHP) vendor/bin/phpstan analyse --no-progress --level 8 src
$(PHP) vendor/bin/phpstan analyse --no-progress --level 6 tests
$(PHP) vendor/bin/psalm --no-progress
$(PHP) bin/console lint:container
$(PHP) bin/console lint:yaml config/
$(PHP) bin/console lint:twig templates/
$(YARN) stylelint "assets/styles/**/*.scss"
.PHONY: tests-unit
tests-unit: APP_ENV=test
tests-unit: PHP_PCOV_ENABLED=1
tests-unit: PHP_XDEBUG_MODE=off
tests-unit:
$(PHP) vendor/bin/phpunit --testsuite "Unit" \
--log-junit var/tests/unit.xml \
--coverage-html coverage/unit/ \
--coverage-clover coverage/unit/coverage.xml
.PHONY: tests-integration
tests-integration: APP_ENV=test
tests-integration: PHP_PCOV_ENABLED=1
tests-integration: PHP_XDEBUG_MODE=off
tests-integration:
$(PHP) vendor/bin/phpunit --testsuite "Integration" \
--log-junit var/tests/integration.xml \
--coverage-html coverage/integration/ \
--coverage-clover coverage/integration/coverage.xml