forked from meako689/FortyTwoTestTask
-
Notifications
You must be signed in to change notification settings - Fork 208
/
Makefile
94 lines (78 loc) · 1.82 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
ifneq (,$(wildcard ./.env))
include .env
export
endif
DOCKER_CMD_PREFIX=./docker/compose.sh
ifeq (,$(USE_LOCAL))
MANAGE=$(DOCKER_CMD_PREFIX) run --rm backend python manage.py
else
MANAGE=python manage.py
endif
TEST_SETTINGS=fortytwo.test_settings
TEST_APP=apps/
# Dev servers
run:
@echo Starting http://127.0.0.1:8000
ifeq (,$(USE_LOCAL))
$(DOCKER_CMD_PREFIX) up
else
(trap 'kill 0' SIGINT; $(MANAGE) runserver & yarn --cwd frontend serve)
endif
# Database
migrate:
$(MANAGE) migrate --noinput
migrations:
$(MANAGE) makemigrations
createcachetable:
@echo Creating cache table
$(MANAGE) createcachetable
initproject: migrate createcachetable
# Testing
shell:
@echo Starting shell...
$(MANAGE) shell
cmd=black apps && flake8 apps
lint:
ifeq (,$(USE_LOCAL))
$(DOCKER_CMD_PREFIX) run backend sh -c "$(cmd)"
else
$(cmd)
endif
djangotest:
$(MANAGE) test --settings=$(TEST_SETTINGS) $(TEST_APP) --noinput
coverage:
coverage run manage.py test --settings=$(TEST_SETTINGS) $(TEST_APP) && coverage report -i
test: lint djangotest
collectstatic:
@echo Collecting static files
$(MANAGE) collectstatic --noinput
eslint:
ifeq (,$(USE_LOCAL))
$(DOCKER_CMD_PREFIX) run frontend sh -c "yarn --cwd /app/frontend lint src --fix"
else
yarn --cwd frontend lint src --fix
endif
# Deploy
DEPLOY_CONT_ID=fortytwotesttask
build:
ifeq (,$(USE_LOCAL))
docker build --tag=$(DEPLOY_CONT_ID):latest .
else
yarn --cwd frontend install
yarn --cwd frontend build
$(MAKE) collectstatic
endif
server:
ifeq (,$(USE_LOCAL))
docker run -p=8000:8000 --rm --name $(DEPLOY_CONT_ID) $(DEPLOY_CONT_ID):latest
else
./docker/backend-cmd.sh
endif
h-deploy:
ifeq (,$(HEROKU_APP_NAME))
@echo Missing HEROKU_APP_NAME env var
else
@echo Deploying on heroku
heroku container:push web --app $(HEROKU_APP_NAME)
heroku container:release web --app $(HEROKU_APP_NAME)
endif