forked from OZ-01-Team3/oz-main_project-be
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
143 lines (112 loc) · 3.4 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
PY = python
MNG = manage.py
MKDIR = mkdir
LN = ln -sf
EXP = export
DJSET = DJANGO_SETTINGS_MODULE
PTR = poetry
CONF = config
SETDIR = settings
SET = settings
SETFILE = $(SET).py
LOC = local
LOCFILE = $(LOC).py
PROD = prod
PRODFILE = $(PROD).py
APPDIR = apps
DCK = docker
DBCONT = psqldb
SCRIPT = ./test.sh
SETTING = --settings=$(CONF).$(SETDIR).$(SET)
LOCSET = --settings=$(CONF).$(SETDIR).$(LOC)
PRODSET = --settings=$(CONF).$(SETDIR).$(PROD)
LCST = locust
CTCD = create_chat_locust_data
.PHONY: all
all:
@echo "Try 'make help'"
.PHONY: help
help: ## 명령어 모음
@grep -E '^[a-zA-Z0-9 -]+:.*#' Makefile | sort | while read -r l; do printf "\033[1;32m$$(echo $$l | cut -f 1 -d':')\033[00m:$$(echo $$l | cut -f 2- -d'#')\n"; done
.PHONY: setlocal
setlocal: ## local에서 settings.py 설정
#$(LN) $(CONF)/$(SETDIR)/$(LOCFILE) $(CONF)/$(SETDIR)/$(SETFILE)
$(LN) $(LOCFILE) $(CONF)/$(SETDIR)/$(SETFILE)
# $(EXP) $(DJSET)=$(CONF).$(LOC)
$(EXP) $(DJSET)=$(CONF).$(SETDIR).$(LOC)
.PHONY: setprod
setprod: ## prod에서 settings.py 설정
# $(LN) $(CONF)/$(SETDIR)/$(PRODFILE) $(CONF)/$(SETDIR)/$(SETFILE)
$(LN) $(PRODFILE) $(CONF)/$(SETDIR)/$(SETFILE)
# $(EXP) $(DJSET)=$(CONF).$(PROD)
#$(EXP) $(DJSET)=$(CONF).$(SETDIR).$(PROD)
.PHONY: runserver
runserver: ## python manage.py runserver
$(PY) $(MNG) runserver
.PHONY: runserverp
runserverp: ## python manage.py runserver
$(PY) $(MNG) runserver $(h):$(p)
.PHONY: uvicorn
uvicorn: ## uvicorn config.asgi:application --workers 4
uvicorn $(CONF).asgi:application --workers 4
.PHONY: gunicorn
gunicorn: ## gunicorn config.asgi:application -c tools/gunicorn_local.conf.py
gunicorn $(CONF).asgi:application -c tools/gunicorn_local.conf.py
.PHONY: migrations
migrations: ## python manage.py makemigrations
$(PY) $(MNG) makemigrations $(a)
.PHONY: makemigrations
makemigrations: ## python manage.py makemigrations
$(PY) $(MNG) makemigrations $(a)
.PHONY: migrate
migrate: ## python manage.py migrate
$(PY) $(MNG) migrate $(a)
.PHONY: showmigrations
showmigrations: ## python manage.py showmigrations
$(PY) $(MNG) showmigrations $(a)
.PHONY: sqlmigrate
sqlmigrate: ## python manage.py sqlmigrate 앱이름 migrations파일번호
$(PY) $(MNG) sqlmigrate $(a) $(n)
.PHONY: shell
shell: ## python manage.py shell_plus --print-sql --quiet-load
$(PY) $(MNG) shell_plus --print-sql --quiet-load
.PHONY: collectstatic
collectstatic: ## python manage.py collectstatic
$(PY) $(MNG) collectstatic
.PHONY: app
app: ## python manage.py startapp 앱이름 ./apps/앱이름
$(MKDIR) $(APPDIR)/$(a)
$(PY) $(MNG) startapp $(a) ./$(APPDIR)/$(a)
@echo "apps.py 가서 name에 apps 붙이기"
.PHONY: superuser
superuser: ## createsuperuser
$(PY) $(MNG) shell < tools/create_superuser.py
.PHONY: test
test: ## python manage.py test
$(PY) $(MNG) test $(a)
.PHONY: bim
bim: $(SCRIPT) ## black, isort, mypy, coverage
$(SCRIPT)
.PHONY: install
install: ## poetry install
$(PTR) install
.PHONY: runstart
runstart: makemigrations migrate runserver ## makemigrations + migrate + runserver
.PHONY: start
start: ## docker db start
$(DCK) start $(DBCONT)
.PHONY: stop
stop: ## docker db stop
$(DCK) stop $(DBCONT)
.PHONY: exec
exec: ## enter the container
$(DCK) exec -it $(DBCONT) /bin/sh
.PHONY: locust
locust: ## start locust runserver
$(LCST) -f $(a)
.PHONY: loctime
loctime:
$(LCST) -f $(a) --run-time $(m)
.PHONY: setlocust
setlocust: ## make user, chatroom for locust test
$(PY) $(MNG) $(CTCD)