-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathMakefile
115 lines (90 loc) · 2.77 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
.PHONY: bash
.PHONY: celery
.PHONY: clear-db
.PHONY: db-reset
.PHONY: dev
.PHONY: flush
.PHONY: generate
.PHONY: help
.PHONY: hooks
.PHONY: indices
.PHONY: lint
.PHONY: Makefile
.PHONY: migrate
.PHONY: migrations
.PHONY: run
.PHONY: services
.PHONY: stop
.PHONY: check-translations
.PHONY: translations
.PHONY: translate
# Trick to allow passing commands to make
# Use quotes (" ") if command contains flags (-h / --help)
args = `arg="$(filter-out $@,$(MAKECMDGOALS))" && echo $${arg:-${1}}`
# If command doesn't match, do not throw error
%:
@:
define helptext
Commands:
bash Open bash in backend container.
celery Run a local celery worker.
clear-db Reset database.
dev Run local backend.
flush-db Flush database.
generate Generate test data via a script.
hooks Add pre-commit hooks.
indices Rebuild search indices.
lint Run pre-commit hooks.
migrate Run database migrations.
migrations Compile database migrations.
run Start docker containers for frontend development.
services Run required services in docker.
stop Stop running containers.
check-translations Check if translations are up to date.
translations Fetch all translation strings under ./locale/.
translate Compile translation strings.
endef
export helptext
# Help should be first so that make without arguments is the same as help
help:
@echo "$$helptext"
bash:
@docker exec -it tvp-core bash
celery:
@celery -A config worker --beat --loglevel=INFO --scheduler=django
clear-db:
@python manage.py dbshell -- -c "DROP SCHEMA $(call args, 'public') CASCADE;CREATE SCHEMA $(call args, 'public');"
dev:
@python manage.py runserver localhost:8000
flush-db:
@python manage.py flush --no-input
generate:
@python manage.py create_test_data
hooks:
@pre-commit install
lint:
@pre-commit run --all-files
migrate:
@python manage.py migrate
migrations:
@python manage.py makemigrations
run:
@docker compose up --detach --build
services:
@docker compose up --detach --build db redis
stop:
@docker compose stop
check-translations:
@python -m config.hooks.translations_done
translations:
@echo ""
@echo Making translations...
@python manage.py maketranslations -l fi -l sv --no-obsolete --omit-header --add-location file
@echo ""
@echo Done!
translate:
@echo ""
@echo Compiling translations...
@python manage.py compilemessages
@echo ""
@echo Done!