-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
225 lines (167 loc) · 8.88 KB
/
Makefile
File metadata and controls
225 lines (167 loc) · 8.88 KB
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
help: ## Display a help message detailing commands and their purpose
@echo "Commands:"
@grep -E '^([a-zA-Z_-]+:.*?## .*|#+ (.*))$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
@echo ""
## [Managing the project]
### Stopping the containers and dropping the databases
stop-sqlite: ## stops the sqlite dev project
$(error SQLite is not supported)
drop-sqlite: ## stops the sqlite dev project
$(error SQLite is not supported)
stop-mysql: ## stops the mysql dev project
$(error MySQL is not supported)
drop-mysql: ## stops the mysql dev project
$(error MySQL is not supported)
stop-psql: ## stops the psql dev project
docker compose down -t 60
drop-psql: ## stops the psql dev project
docker compose down -v -t 60
stop-prod: ## stops the mysql dev project
docker compose -f docker-compose.prod.yml down -t 60
drop-prod: ## stops the mysql dev project
docker compose -f docker-compose.prod.yml down -v -t 60
### Building & starting the containers
up-sqlite: ## run the project with sqlite
$(error SQLite is not supported)
upd-sqlite: ## run the project with sqlite in detached mode
$(error SQLite is not supported)
up-mysql: ## run the project with mysql
$(error MySQL is not supported)
upd-mysql: ## run the project with mysql in detached mode
$(error MySQL is not supported)
up-psql: ## run the project with psql
docker compose up --build
upd-psql: ## run the project with psql in detached mode
docker compose up -d --build
up-prod: ## run the project with mysql
docker compose -f docker-compose.prod.yml up --build
upd-prod: ## run the project with mysql in detached mode
docker compose -f docker-compose.prod.yml up -d --build
build-prod:
docker compose -f docker-compose.prod.yml build \
--build-arg $$(cat .env.prod | grep ENVIRONMENT) \
--build-arg $$(cat .env.prod | grep REACT_APP_CAPTCHA_API_KEY) \
--build-arg $$(cat .env.prod | grep REACT_APP_HERE_MAPS_API_KEY) \
--build-arg $$(cat .env.prod | grep REACT_APP_DJANGO_SITE_URL) \
--build-arg $$(cat .env.prod | grep REACT_APP_DJANGO_PORT) \
--build-arg $$(cat .env.prod | grep REACT_APP_DJANGO_API_ENDPOINT)
### Using the SQLite database
run-sqlite:
$(error SQLite is not supported) ## run the project with sqlite and stop the mysql project beforehand
rund-sqlite:
$(error SQLite is not supported) ## run the project with sqlite in detached mode and stop the mysql project beforehand
redo-sqlite:
$(error SQLite is not supported) ## delete the db and rerun the project with sqlite
redod-sqlite:
$(error SQLite is not supported) ## delete the db and rerun the project with sqlite in detached mode
### Using the MySQL database
run-mysql:
$(error SQLite is not supported) ## run the project with mysql and stop the sqlite project beforehand
rund-mysql:
$(error SQLite is not supported) ## run the project with mysql in detached mode and stop the sqlite project beforehand
redo-mysql:
$(error SQLite is not supported) ## delete the db and rerun the project with mysql
redod-mysql:
$(error SQLite is not supported) ## delete the db and rerun the project with mysql in detached mode
### Using the PostgreSQL database
run-psql: up-psql ## run the project with psql and stop the mysql project beforehand
rund-psql: upd-psql ## run the project with psql in detached mode and stop the mysql project beforehand
redo-psql: drop-psql up-psql ## delete the db and rerun the project with psql
redod-psql: drop-psql upd-psql ## delete the db and rerun the project with psql in detached mode
### With an image built for production
run-prod: up-prod ## run the project with production settings
rund-prod: upd-prod ## run the project with production settings in detached mode
redo-prod: drop-prod up-prod ## delete the db and rerun the project with mysql
redod-prod: drop-prod upd-prod ## delete the db and rerun the project with mysql in detached mode
### Other run options
run: run-psql ## set the default run command to sqlite
redo: redo-psql ## set the default redo command to sqlite
rund: rund-psql ## set the default run command to sqlite
redod: redod-psql ## set the default redo command to sqlite
stop: stop-psql stop-prod ## stop all running projects
drop: drop-psql drop-prod ## drop all databases
## [Monitoring the containers]
logs-dev: ## show the logs of the containers
docker logs -f paul_dev
logs: logs-dev ## set the default logs command to dev
logs-prod: ## show the logs of the containers
docker logs -f paul_prod
## [Operations]
## Django operations
makemigrations: ## generate migrations in a clean container
docker exec paul_app_dev sh -c "cd ./backend && python3 -Wd ./manage.py makemigrations $(apps)"
migrate: ## apply migrations in a clean container
docker exec paul_app_dev sh -c "cd ./backend && python3 -Wd ./manage.py migrate $(apps)"
migrations: makemigrations migrate ## generate and apply migrations
makemessages: ## generate the strings marked for translation
docker exec paul_app_dev sh -c "cd ./backend && python3 -Wd ./manage.py makemessages -a"
compilemessages: ## compile the translations
docker exec paul_app_dev sh -c "cd ./backend && python3 -Wd ./manage.py compilemessages"
messages: makemessages compilemessages ## generate and compile the translations
collectstatic: ## collect the static files
docker exec paul_app_dev sh -c "cd ./backend && python3 -Wd ./manage.py collectstatic --no-input"
format: ## format the code with ruff
docker exec paul_app_dev sh -c " \
cd ./backend && \
ruff format . && \
ruff check --select I --fix . && \
cd ../frontend && \
npm run prettier:format"
check:
docker exec paul_app_dev sh -c " \
cd ./backend && \
ruff check --select I . && \
ruff format --check . && \
cd ../frontend && \
npm run prettier:check && \
npm run lint"
pyshell: ## start a django shell
docker exec -it paul_app_dev sh -c "cd ./backend && python3 -Wd ./manage.py shell"
sh: ## start a sh shell
docker exec -it paul_app_dev sh -c "sh"
bash: ## start a bash shell
docker exec -it paul_app_dev sh -c "bash"
## Node.js operations
i18n-scan: ## scan the frontend for i18n strings
docker exec paul_app_dev sh -c "cd ./frontend && npm run i18n:scan"
i18n-generate-types:
docker exec paul_app_dev sh -c "cd ./frontend && npm run i18n:generate-types"
i18n-check-missing:
docker exec paul_app_dev sh -c "cd ./frontend && npm run i18n:check-missing"
i18n-validate:
docker exec paul_app_dev sh -c "cd ./frontend && npm run i18n:validate"
## [Requirements management]
requirements-build: ## run uv to build the requirements files using the active venv
docker exec paul_app_dev sh -c " \
cd ./backend && \
uv sync --active \
"
requirements-update: ## run uv with the -U flag to update the requirements files using the active venv
docker exec paul_app_dev sh -c " \
cd ./backend && \
uv sync --active -U \
"
## [Tests]
tests: ## run the tests
docker exec paul_app_dev sh -c "cd ./backend && pytest -Wd $(apps)"
tests-cover: ## run the tests with coverage
docker exec paul_app_dev sh -c "cd ./backend && pytest -Wd --cov --cov-report=xml --cov-report=term-missing --cov-fail-under=60 $(apps)"
## [Clean-up]
clean-docker: ## stop docker containers and remove orphaned images and volumes
docker compose down -t 60
docker compose -f docker-compose.prod.yml down -t 60
docker system prune -f
clean-extras: ## remove test, coverage, file artifacts, and compiled message files
find ./backend -name '*.mo' -delete
find ./backend -name '*.pyc' -delete
find ./backend -name '*.pyo' -delete
find ./backend -name '.coverage' -delete
find ./backend -name '.pytest_cache' -delete
find ./backend -name '.ruff_cache' -delete
find ./backend -name '__pycache__' -delete
find ./backend -name 'htmlcov' -delete
clean-db: ## remove the database files
rm -rf ./backend/media ./backend/static ./frontend/dist
clean: clean-docker clean-extras clean-db ## remove all build, test, coverage and Python artifacts
reset-node-modules:
docker exec paul_app_dev sh -c "cd ./frontend && rm -rf node_modules && npm ci"