-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathMakefile
More file actions
180 lines (145 loc) · 5.62 KB
/
Makefile
File metadata and controls
180 lines (145 loc) · 5.62 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
# =============================================================================
# Boost Data Collector – Developer Makefile
# Wraps docker compose + common Django management commands.
#
# Usage: make <target>
# make help → list all targets
# =============================================================================
SHELL := /bin/bash
COMPOSE := docker compose
APP := web
BEAT := celery_beat
MANAGE := $(COMPOSE) run --rm $(APP) python manage.py
.DEFAULT_GOAL := help
# ── Help ─────────────────────────────────────────────────────────────────────
.PHONY: help
help:
@echo ""
@echo "Usage: make <target>"
@echo ""
@echo " Stack"
@echo " build Build (or rebuild) all images"
@echo " up Clean macOS files, then start all services (detached)"
@echo " down Stop and remove containers (volumes kept)"
@echo " stop Pause all containers (fast restart)"
@echo " start Resume paused containers"
@echo " restart Stop then start all containers"
@echo " reset !! Remove containers AND volumes (wipes DB + data)"
@echo ""
@echo " Logs & status"
@echo " ps Show running containers"
@echo " health Verify DB, Redis, Selenium, and Celery containers"
@echo " notify Send Slack/Discord startup notification (celery_beat; optional DEPLOY_BRANCH)"
@echo " logs Follow logs for all services"
@echo " logs-web Follow logs for the web service"
@echo " logs-worker Follow logs for the Celery worker"
@echo " logs-beat Follow logs for the Celery beat"
@echo ""
@echo " Django"
@echo " migrate Apply database migrations"
@echo " makemigrations Create new migration files"
@echo " superuser Create a Django superuser"
@echo " shell Open Django shell inside the web container"
@echo " bash Open a bash shell inside the web container"
@echo " collectstatic Collect static files"
@echo ""
@echo " Testing (runs locally, not inside Docker)"
@echo " test Run full pytest suite"
@echo " test-fast Run tests, stop on first failure"
@echo " test-cov Run tests with coverage report"
@echo ""
@echo " Utilities"
@echo " clean-mac Remove macOS ._* resource-fork files"
@echo " clean-pyc Remove compiled Python files"
@echo " clean Run clean-mac + clean-pyc"
@echo ""
# ── Stack ─────────────────────────────────────────────────────────────────────
.PHONY: build
build: clean-mac
$(COMPOSE) build
.PHONY: up
up: clean-mac
$(COMPOSE) up -d
.PHONY: down
down:
$(COMPOSE) down
.PHONY: stop
stop:
$(COMPOSE) stop
.PHONY: start
start:
$(COMPOSE) start
.PHONY: restart
restart: stop start
.PHONY: reset
reset:
@echo "WARNING: This will delete all containers AND volumes (database, workspace, logs)."
@read -r -p "Type 'yes' to confirm: " confirm && [ "$$confirm" = "yes" ] || (echo "Aborted."; exit 1)
$(COMPOSE) down -v
# ── Logs & status ─────────────────────────────────────────────────────────────
.PHONY: ps
ps:
$(COMPOSE) ps
.PHONY: health
health:
$(COMPOSE) exec -T $(APP) python manage.py check --database default
$(COMPOSE) exec -T redis redis-cli ping | grep -q PONG
$(COMPOSE) exec -T selenium curl -sf http://localhost:4444/status | grep -qE '"ready"[[:space:]]*:[[:space:]]*true'
$(COMPOSE) ps --status running celery_worker | grep -q celery_worker
$(COMPOSE) ps --status running celery_beat | grep -q celery_beat
.PHONY: notify
notify:
$(COMPOSE) exec -T -e DEPLOY_BRANCH="$(DEPLOY_BRANCH)" $(BEAT) python manage.py send_startup_notification
.PHONY: logs
logs:
$(COMPOSE) logs -f
.PHONY: logs-web
logs-web:
$(COMPOSE) logs -f web
.PHONY: logs-worker
logs-worker:
$(COMPOSE) logs -f celery_worker
.PHONY: logs-beat
logs-beat:
$(COMPOSE) logs -f celery_beat
# ── Django ────────────────────────────────────────────────────────────────────
.PHONY: migrate
migrate:
$(MANAGE) migrate
.PHONY: makemigrations
makemigrations:
$(MANAGE) makemigrations
.PHONY: superuser
superuser:
$(MANAGE) createsuperuser
.PHONY: shell
shell:
$(MANAGE) shell
.PHONY: bash
bash:
$(COMPOSE) exec $(APP) bash
.PHONY: collectstatic
collectstatic:
$(MANAGE) collectstatic --noinput
# ── Testing (runs locally, not inside the production image) ───────────────────
.PHONY: test
test:
python -m pytest
.PHONY: test-fast
test-fast:
python -m pytest -x --tb=short
.PHONY: test-cov
test-cov:
python -m pytest --tb=short --cov=. --cov-report=term-missing
# ── Utilities ─────────────────────────────────────────────────────────────────
.PHONY: clean-mac
clean-mac:
@find . -name '._*' -not -path './.git/*' -delete 2>/dev/null && \
echo "Removed macOS ._* files." || true
.PHONY: clean-pyc
clean-pyc:
@find . -type f -name '*.pyc' -delete && \
find . -type d -name '__pycache__' -delete && \
echo "Removed .pyc and __pycache__."
.PHONY: clean
clean: clean-mac clean-pyc