# Makefile
注意
- Makefile indent 吃 tab 而非space -> 建議可裝 makefile plugin 協助偵錯
- .PHONY 的設定
- EditorConfig 設定Makefile
- 在你的專案目錄下面新增一個
.editorconfig
, 加入以下內容, IDE(如phpStorm) 就會抓取到設定
- 在你的專案目錄下面新增一個
# Tab indentation (no size specified)
[Makefile]
indent_style = tab
1
2
3
2
3
# PHONY 的用法
- 舉例
make vendor: composer install
- 下完
make vendor
後, 正好 composer 更新會產生vendor
資料夾, 故再次下make vendor
就會錯誤 - 此情況下, 就要設定
.PHONY: vendor
# Makefile範例
- @jobfinder
#!/usr/bin/make -f
include .env
export
BRANCH := $(shell git name-rev --name-only HEAD)
PHP_CONTAINER := jf_dev_phpfpm
.PHONY: build update-d update-f gulp-watch
all: env-build start build init-db init-data
build: update-d update-f
# Git Related
pull:
@echo ">>> Pull Code on Current branch [$(BRANCH)]"
git pull origin $(BRANCH) --rebase
push:
@echo ">>> Current branch [$(BRANCH)] Pushing Code"
git push origin $(BRANCH)
# Use the System
start: cp_conf
docker-compose up -d --no-recreate
chmod 777 resources
@echo ">>> Start: Visit http://localhost:9487 ...."
stop:
docker-compose stop
update-d:
composer install
update-f:
npm install
gulp-watch:
gulp watch
# Environment Related
env-build: docker-build
cp_conf:
cp _conf/default.conf /tmp
docker-build:
docker-compose build --parallel
docker-destroy:
docker-compose down --remove-orphans
destroy: docker-destroy
rm -rf vendor && rm -rf node_modules
rebuild: destroy all
# DB init
init-db:
docker exec -it $(PHP_CONTAINER) php artisan migrate
# Data Init
init-data:
cp resources/json/condition.sample.json resources/json/condition.json
# Behavior
update-104-jobs:
php artisan update:jobs 104
update-companies:
php artisan update:companies
# Behavior w/Docker
dk-update-jobs:
docker exec -it $(PHP_CONTAINER) php artisan update:jobs 104
dk-update-companies:
docker exec -it $(PHP_CONTAINER) php artisan update:companies
refresh: dk-update-jobs dk-update-companies
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
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