Makefile 2.57 KB
Newer Older
Florent Chehab's avatar
Florent Chehab committed
1
.PHONY: documentation
2

Florent Chehab's avatar
Florent Chehab committed
3
setup:
4
	bash server/envs/init.sh
Florent Chehab's avatar
Florent Chehab committed
5
6

clear_setup:
7
8
	rm server/envs/db.env
	rm server/envs/django.env
Florent Chehab's avatar
Florent Chehab committed
9
10

up: setup
11
	docker-compose up --build --renew-anon-volumes
12
13
14
15
16
17
18
19

dev: up

down_dev:
	docker-compose down

init_dev_data:
	docker-compose exec backend sh -c "cd backend && ./manage.py shell < init_dev_data.py"
20

21
22
23
init_prod_data:
	docker-compose $(prod_yml) exec backend sh -c "cd backend && ./manage.py shell < init_prod_data.py"

Florent Chehab's avatar
Florent Chehab committed
24
25
docker-pull:
	docker-compose pull
Florent Chehab's avatar
Florent Chehab committed
26

Florent Chehab's avatar
Florent Chehab committed
27
28
29
reformat_backend:
	docker-compose exec backend sh -c "cd backend && black ."

30
31
32
33
34
35
reformat_frontend:
	docker-compose exec frontend sh -c "cd frontend && yarn reformat"

reformat_documentation:
	docker-compose exec frontend sh -c "cd frontend && yarn reformat-doc"

Florent Chehab's avatar
Florent Chehab committed
36
test_backend:
37
	docker-compose exec backend sh -c "cd backend && pytest --cov --cov-config .coveragerc --cov-report term base_app/ backend_app/ stats_app/"
38

39
test_frontend:
40
	docker-compose exec frontend sh -c "cd frontend && yarn test"
41

Florent Chehab's avatar
Florent Chehab committed
42
check_backend:
Florent Chehab's avatar
Florent Chehab committed
43
44
45
	docker-compose exec backend sh -c "cd backend && ./manage.py check"

lint_backend:
Maxime Emschwiller's avatar
Maxime Emschwiller committed
46
	docker-compose exec backend sh -c "cd backend && black --check . && flake8"
Florent Chehab's avatar
Florent Chehab committed
47
48

lint_frontend:
49
	docker-compose exec frontend sh -c "cd frontend && yarn lint"
Florent Chehab's avatar
Florent Chehab committed
50

51
52
53
lint_documentation:
	docker-compose exec frontend sh -c "cd frontend && yarn lint-doc"

Florent Chehab's avatar
Florent Chehab committed
54
build_frontend:
55
	docker-compose exec frontend sh -c "cd frontend && yarn build"
56

Florent Chehab's avatar
Florent Chehab committed
57
shell_backend:
58
	docker-compose exec backend sh -c "cd backend && bash"
59

Florent Chehab's avatar
Florent Chehab committed
60
shell_frontend:
61
62
63
64
	docker-compose exec frontend sh -c "cd frontend && sh"

django_shell:
	docker-compose exec backend sh -c "cd backend && ./manage.py shell"
65

Florent Chehab's avatar
Florent Chehab committed
66
# Create or update UML diagrams for the documentation
67
documentation:
Florent Chehab's avatar
Florent Chehab committed
68
69
	docker-compose exec backend bash -c "cd documentation && make extract_django"
	docker-compose exec gen_doc_uml bash -c "cd /usr/src/app/documentation && make convert_to_svg"
70

71
documentation_clean:
Florent Chehab's avatar
Florent Chehab committed
72
	docker-compose exec backend bash -c "cd documentation && make clean"
73
74
75
76
77
78

prod_yml = -f ./server/docker-compose.prod.yml

prod: setup
	$(info In production, we need to reset the webpack-stats.json file to make sure the front is up-to-date)
	sudo rm -f frontend/webpack-stats.json
79
	# Need higher compose timeout as the big map container can take a lot of time to wake up
80
	COMPOSE_HTTP_TIMEOUT=600 docker-compose $(prod_yml) up --build -d --renew-anon-volumes
81
82
83
84

down_prod:
	docker-compose $(prod_yml) down

85
86
87
prod_docker_logs:
	docker-compose $(prod_yml) logs

88
89
90
91
92
shell_prod_logs:
	docker-compose $(prod_yml) exec logs_rotation /bin/sh -c "cd /var/log && /bin/sh"

shell_backend_prod:
	docker-compose $(prod_yml) exec backend sh -c "cd backend && bash"