-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
206 lines (165 loc) · 5.7 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
.PHONY: up start stop down log artisan migrate migrate\:fresh migrate\:rollback scrap phone import composer composer\:update supervisor-update permissions\:fix fpm-reload ide-helper tests phpstan deploy yarn nginx-check nginx-reload debug\:enable debug\:disable debug\:coverage pm2\:start pm2\:restart pm2\:stop pm2\:delete postgres\:fix
include .env
%::
@true
# Takes the first target as command
Command := $(firstword $(MAKECMDGOALS))
# Skips the first word
args := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
# Set dir of Makefile to a variable to use later
MAKEPATH := $(abspath $(lastword $(MAKEFILE_LIST)))
PWD := $(dir $(MAKEPATH))
CONTAINER_FPM := $(shell docker ps --format 'table {{.Names}}' | grep -m 1 $(APP_NAME)_fpm)
CONTAINER_WEB := $(shell docker ps --format 'table {{.Names}}' | grep -m 1 $(APP_NAME)_web)
CONTAINER_NODE := $(shell docker ps --format 'table {{.Names}}' | grep -m 1 $(APP_NAME)_nodejs)
UID := 1000
COMPOSE_PROJECT_NAME := $(APP_NAME)
up:
docker-compose -p $(COMPOSE_PROJECT_NAME) up -d
start:
docker-compose -p $(COMPOSE_PROJECT_NAME) start
stop:
docker-compose -p $(COMPOSE_PROJECT_NAME) stop
down:
docker-compose -p $(COMPOSE_PROJECT_NAME) down
reboot:
docker-compose -p $(COMPOSE_PROJECT_NAME) down && docker-compose -p $(COMPOSE_PROJECT_NAME) up -d
artisan:
docker exec -it \
-u $(UID) \
-e XDEBUG_MODE=off \
$(CONTAINER_FPM) \
php artisan $(args) \
2>/dev/null || true
host?="127.0.0.1"
artisan\:debug:
docker exec -it \
-u $(UID) \
-e XDEBUG_CONFIG="mode=debug client_host=$(host) client_port=9000 start_with_request=yes" \
-e PHP_IDE_CONFIG="serverName=dockerhost" \
$(CONTAINER_FPM) \
php artisan $(args) -vvv \
2>/dev/null || true
migrate:
docker exec -it \
-u $(UID) \
-e XDEBUG_MODE=off \
$(CONTAINER_FPM) \
php artisan migrate \
2>/dev/null || true
migrate\:fresh:
docker exec -it \
-u $(UID) \
-e XDEBUG_MODE=off \
$(CONTAINER_FPM) \
php artisan migrate:fresh \
2>/dev/null || true
migrate\:rollback:
docker exec -it \
-u $(UID) \
-e XDEBUG_MODE=off \
$(CONTAINER_FPM) \
php artisan migrate:rollback \
2>/dev/null || true
seed:
docker exec -it \
-u $(UID) \
-e XDEBUG_MODE=off \
$(CONTAINER_FPM) \
php artisan db:seed \
2>/dev/null || true
migrate\:fresh\:seed:
docker exec -it \
-u $(UID) \
-e XDEBUG_MODE=off \
$(CONTAINER_FPM) \
php artisan migrate:fresh --seed \
2>/dev/null || true
nginx\:check:
docker exec -it $(CONTAINER_WEB) nginx -t 2>/dev/null || true
nginx\:reload:
docker kill -s HUP $(CONTAINER_WEB) 2>/dev/null || true
composer:
docker exec -it \
-u $(UID) \
$(CONTAINER_FPM) \
composer $(args) \
2>/dev/null || true
composer\:update:
docker exec -it \
-u $(UID) \
$(CONTAINER_FPM) \
composer update -o \
2>/dev/null || true
ide-helper:
docker exec -it -u $(UID) -e XDEBUG_MODE=off $(CONTAINER_FPM) php artisan ide-helper:generate stubs/IdeHelper.php 2>/dev/null || true && \
docker exec -it -u $(UID) -e XDEBUG_MODE=off $(CONTAINER_FPM) php artisan ide-helper:models --write-mixin -F stubs/ModelHelper.php 2>/dev/null || true && \
docker exec -it -u $(UID) -e XDEBUG_MODE=off $(CONTAINER_FPM) php artisan ide-helper:eloquent 2>/dev/null || true
cache\:clear:
docker exec -it -u $(UID) -e XDEBUG_MODE=off $(CONTAINER_FPM) php artisan cache:clear 2>/dev/null || true && \
docker exec -it -u $(UID) -e XDEBUG_MODE=off $(CONTAINER_FPM) php artisan view:clear 2>/dev/null || true && \
docker exec -it -u $(UID) -e XDEBUG_MODE=off $(CONTAINER_FPM) php artisan route:clear 2>/dev/null || true && \
docker exec -it -u $(UID) -e XDEBUG_MODE=off $(CONTAINER_FPM) php artisan config:clear 2>/dev/null || true
logs\:clear:
docker exec -it $(CONTAINER_FPM) truncate -s 0 storage/logs/*.log 2>/dev/null || true
tests:
docker exec -it \
-u $(UID) \
$(CONTAINER_FPM) \
php ./vendor/bin/pest --do-not-cache-result --no-coverage \
2>/dev/null || true
phpstan:
docker exec -it \
-u $(UID) \
$(CONTAINER_FPM) \
php ./vendor/bin/phpstan analyse --memory-limit 1024M $(args) \
2>/dev/null || true
deploy:
envoy run deploy
backup:
docker exec -it -u $(UID) $(CONTAINER_FPM) php artisan backup:run 2>/dev/null || true
permissions\:fix:
docker exec -u 0 -it $(CONTAINER_FPM) chown -R 1000:100 ./bootstrap 2>/dev/null || true && \
docker exec -u 0 -it $(CONTAINER_FPM) chown -R 1000:100 ./storage/logs 2>/dev/null || true && \
docker exec -u 0 -it $(CONTAINER_FPM) chown -R 1000:100 ./storage/framework 2>/dev/null || true && \
docker exec -u 0 -i $(CONTAINER_FPM) find ./vendor -type d -exec chmod 755 {} \; 2>/dev/null || true && \
docker exec -u 0 -i $(CONTAINER_FPM) find ./vendor -type f -exec chmod 644 {} \; 2>/dev/null || true
fpm\:reload:
docker exec -it $(CONTAINER_FPM) kill -USR2 1
cmd=""
yarn:
docker exec \
$(CONTAINER_NODE) \
yarn $(cmd) -t \
2>/dev/null || true
debug\:enable:
echo "xdebug.mode = develop,debug" > ./.docker/php/custom.ini && \
docker exec -it $(CONTAINER_FPM) kill -USR2 1
debug\:disable:
echo ";xdebug.mode = develop,debug" > ./.docker/php/custom.ini && \
docker exec -it $(CONTAINER_FPM) kill -USR2 1
debug\:coverage:
echo -e "xdebug.mode = develop,debug,coverage" > ./.docker/php/custom.ini && \
docker exec -it $(CONTAINER_FPM) kill -USR2 1
pm2\:start:
pm2 start pm2.yml
pm2\:restart:
pm2 restart pm2.yml
pm2\:stop:
pm2 stop pm2.yml
pm2\:delete:
pm2 delete pm2.yml
db_username?="$(DB_USERNAME)"
db_password?="$(DB_PASSWORD)"
db_name?="$(DB_DATABASE)"
db_host?="$(DB_HOST)"
table_name=""
postgres\:fix:
docker exec -it -u $(UID) \
-e PGPASSWORD=$(db_password) \
$(CONTAINER_FPM) \
psql -U $(db_username) \
-d $(db_name) \
-h $(db_host) \
-c "SELECT SETVAL('$(table_name)_id_seq', COALESCE(MAX(id), 1)) FROM $(table_name);" \
2>/dev/null || true