5
5
# https://docs.docker.com/compose/environment-variables/envvars/
6
6
export DOCKER_BUILDKIT ?= 1
7
7
8
+ # Docker binary to use, when executing docker tasks
9
+ DOCKER ?= docker
10
+
8
11
# Binary to use, when executing docker-compose tasks
9
- DOCKER_COMPOSE ?= docker compose
12
+ DOCKER_COMPOSE ?= $( DOCKER ) compose
10
13
11
14
# Support image with all needed binaries, like envsubst, mkcert, wait4x
12
15
SUPPORT_IMAGE ?= wayofdev/build-deps:alpine-latest
13
16
14
17
APP_RUNNER ?= $(DOCKER_COMPOSE ) run --rm --no-deps app
15
- APP_EXEC ?= $(DOCKER_COMPOSE ) exec app
16
18
APP_COMPOSER ?= $(APP_RUNNER ) composer
19
+ APP_EXEC ?= $(DOCKER_COMPOSE ) exec app
17
20
18
21
BUILDER_PARAMS ?= docker run --rm -i \
19
22
--env-file ./.env \
@@ -32,14 +35,34 @@ WAITER ?= $(BUILDER_WIRED) wait4x
32
35
# Shorthand envsubst command, executed through build-deps
33
36
ENVSUBST ?= $(BUILDER ) envsubst
34
37
38
+ # Yamllint docker image
39
+ YAML_LINT_RUNNER ?= $(DOCKER ) run --rm $$(tty -s && echo "-it" || echo ) \
40
+ -v $(PWD ) :/data \
41
+ cytopia/yamllint:latest \
42
+ -c ./.github/.yamllint.yaml \
43
+ -f colored .
44
+
45
+ ACTION_LINT_RUNNER ?= $(DOCKER ) run --rm $$(tty -s && echo "-it" || echo ) \
46
+ -v $(shell pwd) :/repo \
47
+ --workdir /repo \
48
+ rhysd/actionlint:latest \
49
+ -color
50
+
51
+ MARKDOWN_LINT_RUNNER ?= $(DOCKER ) run --rm $$(tty -s && echo "-it" || echo ) \
52
+ -v $(shell pwd) :/app \
53
+ --workdir /app \
54
+ davidanson/markdownlint-cli2-rules:latest
55
+
56
+ PHIVE_RUNNER ?= $(DOCKER_COMPOSE ) run --rm --no-deps app
57
+
35
58
EXPORT_VARS = '\
36
59
$${APP_NAME} \
37
60
$${COMPOSE_PROJECT_NAME} \
38
61
$${PROJECT_SERVICES_NAMESPACE} \
39
62
$${SHARED_SERVICES_NAMESPACE} \
40
63
$${COMPOSER_AUTH}'
41
64
42
-
65
+ #
43
66
# Self documenting Makefile code
44
67
# ------------------------------------------------------------------------------------
45
68
ifneq ($(TERM ) ,)
63
86
WHITE := ""
64
87
RST := ""
65
88
endif
66
- MAKE_LOGFILE = /tmp/laravel-starter-tpl.log
89
+ MAKE_LOGFILE = /tmp/wayofdev- laravel-starter-tpl.log
67
90
MAKE_CMD_COLOR := $(BLUE )
68
91
69
92
default : all
70
93
71
94
help : # # Show this menu
72
- echo ${MAKEFILE_LIST}
73
-
74
- @echo 'Management commands for package:'
95
+ @echo ' Management commands for project:'
75
96
@echo ' Usage:'
76
97
@echo ' ${MAKE_CMD_COLOR}make${RST} Prepares and spins up project with default settings'
77
98
@grep -E ' ^[a-zA-Z_0-9%-]+:.*?## .*$$' Makefile | awk ' BEGIN {FS = ":.*?## "}; {printf " ${MAKE_CMD_COLOR}make %-21s${RST} %s\n", $$1, $$2}'
78
99
@echo
79
100
@echo ' 📑 Logs are stored in $(MAKE_LOGFILE)'
80
101
@echo
81
- @echo ' 📦 Package laravel-starter-tpl (github.com/wayofdev/laravel-starter-tpl)'
82
- @echo ' 🤠 Author Andrij Orlenko (github.com/lotyp)'
83
- @echo ' 🏢 ${YELLOW}Org wayofdev (github.com/wayofdev)${RST}'
102
+ @echo ' 📦 Project laravel-starter-tpl (https://github.com/wayofdev/laravel-starter-tpl)'
103
+ @echo ' 🤠 Author Andrij Orlenko (https://github.com/lotyp)'
104
+ @echo ' 🏢 ${YELLOW}Org wayofdev (https://github.com/wayofdev)${RST}'
105
+ @echo
84
106
.PHONY : help
85
107
86
108
.EXPORT_ALL_VARIABLES :
87
109
110
+ #
88
111
# Default action
89
112
# Defines default command when `make` is executed without additional parameters
90
113
# ------------------------------------------------------------------------------------
91
114
all : hooks install key prepare up
92
115
.PHONY : all
93
116
94
-
117
+ #
95
118
# System Actions
96
119
# ------------------------------------------------------------------------------------
97
120
override-create : # # Generate override file from dist
@@ -119,23 +142,31 @@ prepare:
119
142
mkdir -p app/.build/php-cs-fixer
120
143
.PHONY : prepare
121
144
122
-
145
+ #
123
146
# Docker Actions
124
147
# ------------------------------------------------------------------------------------
125
148
up : # Creates and starts containers, defined in docker-compose and override file
126
149
$(DOCKER_COMPOSE ) up --remove-orphans -d
150
+ @sleep 1
127
151
$(DOCKER_COMPOSE ) exec app wait4x postgresql ' postgres://${DB_USERNAME}:${DB_PASSWORD}@database:5432/${DB_DATABASE}?sslmode=disable' -t 1m
128
152
.PHONY : up
129
153
130
154
down : # Stops and removes containers of this project
131
155
$(DOCKER_COMPOSE ) down --remove-orphans
132
156
.PHONY : down
133
157
158
+ purge : # # Stops and removes containers, volumes, networks and images
159
+ $(DOCKER_COMPOSE ) down --remove-orphans --volumes
160
+ $(DOCKER ) network prune --force
161
+ $(DOCKER ) volume prune --force
162
+ $(DOCKER ) image prune --force
163
+ .PHONY : purge
164
+
134
165
restart : down up # # Runs down and up commands
135
166
.PHONY : restart
136
167
137
- clean : # # Stops containers if required and removes from system
138
- $(DOCKER_COMPOSE ) rm --force --stop
168
+ clean : # # Stops and removes containers of this project together with volumes
169
+ $(DOCKER_COMPOSE ) rm --force --stop --volumes
139
170
.PHONY : clean
140
171
141
172
ps : # # List running project containers
@@ -154,18 +185,57 @@ ssh: ## Login inside running docker container
154
185
$(APP_EXEC ) sh
155
186
.PHONY : ssh
156
187
188
+ #
189
+ # Composer Commands
190
+ # ------------------------------------------------------------------------------------
191
+ install : # # Install composer dependencies
192
+ $(APP_COMPOSER ) install
193
+ .PHONY : install
194
+
195
+ update : # # Update composer dependencies
196
+ $(APP_COMPOSER ) update $(package )
197
+ .PHONY : update
198
+
199
+ du : # # Dump composer autoload
200
+ $(APP_COMPOSER ) dump-autoload
201
+ .PHONY : du
157
202
158
- # Code Quality, Git, Linting, Testing
203
+ show : # # Shows information about installed composer packages
204
+ $(APP_COMPOSER ) show
205
+ .PHONY : show
206
+
207
+ phive : # # Installs dependencies with phive
208
+ $(APP_RUNNER ) /usr/local/bin/phive install --trust-gpg-keys 0xC00543248C87FB13,0x033E5F8D801A2F8D,0x47436587D82C4A39
209
+ .PHONY : phive
210
+
211
+ #
212
+ # Code Quality, Git, Linting
159
213
# ------------------------------------------------------------------------------------
160
214
hooks : # # Install git hooks from pre-commit-config
161
215
pre-commit install
216
+ pre-commit install --hook-type commit-msg
162
217
pre-commit autoupdate
163
218
.PHONY : hooks
164
219
220
+ lint : lint-yaml lint-actions lint-md lint-php lint-stan lint-composer lint-audit # # Runs all linting commands
221
+ .PHONY : lint
222
+
165
223
lint-yaml : # # Lints yaml files inside project
166
- yamllint .
224
+ @ $( YAML_LINT_RUNNER ) | tee -a $( MAKE_LOGFILE )
167
225
.PHONY : lint-yaml
168
226
227
+ lint-actions : # # Lint all github actions
228
+ @$(ACTION_LINT_RUNNER ) | tee -a $(MAKE_LOGFILE )
229
+ .PHONY : lint-actions
230
+
231
+ lint-md : # # Lint all markdown files using markdownlint-cli2
232
+ @$(MARKDOWN_LINT_RUNNER ) --fix " **/*.md" " !CHANGELOG.md" " !app/vendor" " !app/node_modules" | tee -a $(MAKE_LOGFILE )
233
+ .PHONY : lint-md
234
+
235
+ lint-md-dry : # # Lint all markdown files using markdownlint-cli2 in dry-run mode
236
+ @$(MARKDOWN_LINT_RUNNER ) " **/*.md" " !CHANGELOG.md" " !app/vendor" " !app/node_modules" | tee -a $(MAKE_LOGFILE )
237
+ .PHONY : lint-md-dry
238
+
169
239
lint-php : # # Lints php files inside project using php-cs-fixer
170
240
$(APP_COMPOSER ) cs:fix
171
241
.PHONY : lint-php
@@ -182,10 +252,27 @@ lint-stan-baseline: ## Runs phpstan to update its baseline
182
252
$(APP_COMPOSER ) stan:baseline
183
253
.PHONY : lint-stan-baseline
184
254
185
- lint-deps :
186
- $(APP_COMPOSER ) deptrac
255
+ lint-deps : # # Runs composer-require-checker – checks for dependencies that are not used
256
+ $(APP_RUNNER ) .phive/composer-require-checker check \
257
+ --config-file=/app/composer-require-checker.json \
258
+ --verbose
187
259
.PHONY : lint-deps
188
260
261
+ lint-ddd-deps :
262
+ $(APP_RUNNER ) .phive/deptrac
263
+ .PHONY : lint-ddd-deps
264
+
265
+ lint-composer : # # Normalize composer.json and composer.lock files
266
+ $(APP_RUNNER ) .phive/composer-normalize normalize
267
+ .PHONY : lint-composer
268
+
269
+ lint-audit : # # Runs security checks for composer dependencies
270
+ $(APP_COMPOSER ) audit
271
+ .PHONY : lint-security
272
+
273
+ #
274
+ # Testing
275
+ # ------------------------------------------------------------------------------------
189
276
test : # # Run project php-unit and pest tests
190
277
$(APP_COMPOSER ) test
191
278
.PHONY : test
@@ -199,23 +286,7 @@ api-docs: ## Generate openapi docs specification file
199
286
.PHONY : api-docs
200
287
201
288
202
- # Composer Commands
203
- # ------------------------------------------------------------------------------------
204
- install : # # Install composer dependencies
205
- $(APP_COMPOSER ) install
206
- .PHONY : install
207
289
208
- update : # # Update composer dependencies
209
- $(APP_COMPOSER ) update $(package )
210
- .PHONY : update
211
-
212
- du : # # Dump composer autoload
213
- $(APP_COMPOSER ) dump-autoload
214
- .PHONY : du
215
-
216
- show : # # Shows information about installed composer packages
217
- $(APP_COMPOSER ) show
218
- .PHONY : show
219
290
220
291
221
292
# Database Commands
0 commit comments