-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
447 lines (377 loc) · 22.4 KB
/
Copy pathmakefile
File metadata and controls
447 lines (377 loc) · 22.4 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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
.PHONY: help dev-init create-version delete-version dev-front dev-php dev-python dev-node prod-php prod-python prod-node status ps down down-all logs logs-nginxproxy clean composer-install composer-update composer-dumpautoload composer db-create db-migrate db-migrate-create db-schema-update db-schema-validate queue-up queue-down test-telemetry test-telemetry-null test-telemetry-real test-telemetry-config test-telemetry-factory test-telemetry-di test-telemetry-integration test-telemetry-profiles test-telemetry-attribute-groups test-telemetry-filtering test-telemetry-monolog test-telemetry-monolog-e2e test-telemetry-profiles-e2e test-telemetry-e2e test-telemetry-app-events test-telemetry-app-lifecycle test-telemetry-ui-events test-telemetry-action-events test-telemetry-api-calls test-telemetry-error-tracking test-telemetry-session-context test-telemetry-frontend-events test-telemetry-frontend-e2e
# Variables
DOCKER_COMPOSE = docker-compose
CURRENT_UID := $(shell id -u):$(shell id -g)
# Default target - show help
help: ## Show this help message
@echo "🚀 Bitrix24 AI Starter - Available Commands"
@echo "=========================================="
@echo ""
@echo "📋 Setup & Initialization:"
@echo " dev-init Interactive project setup (recommended)"
@echo " create-version Clone current project into versions/<name>"
@echo " delete-version Remove versions/<name>"
@echo ""
@echo "🛠 Development:"
@echo " dev-front Start frontend only"
@echo " dev-php Start with PHP backend"
@echo " dev-python Start with Python backend"
@echo " dev-node Start with Node.js backend"
@echo ""
@echo "🚀 Production:"
@echo " prod-php Deploy PHP backend to production"
@echo " prod-python Deploy Python backend to production"
@echo " prod-node Deploy Node.js backend to production"
@echo ""
@echo "🐘 PHP Tools:"
@echo " composer-install Install PHP dependencies"
@echo " composer-update Update PHP dependencies"
@echo " php-cli-sh Access PHP CLI container shell"
@echo ""
@echo "🗄 Database (PHP):"
@echo " dev-php-init-database Initialize PHP database"
@echo " dev-php-db-create Create PHP database"
@echo " dev-php-db-migrate Run PHP migrations"
@echo ""
@echo "🔍 Monitoring:"
@echo " status Show Docker stats"
@echo " ps Watch Docker processes"
@echo " logs Show all container logs"
@echo ""
@echo "🧹 Cleanup:"
@echo " down Stop all containers and remove orphans"
@echo " clean Complete Docker cleanup (containers, networks, volumes)"
@echo " down-all Stop all containers including server compose"
@echo ""
@echo "📨 Queues:"
@echo " queue-up Start RabbitMQ only (profile queue)"
@echo " queue-down Stop RabbitMQ only"
@echo ""
@echo "🔧 Troubleshooting:"
@echo " fix-php Fix PHP backend dependencies"
@echo ""
@echo "🛡 Security:"
@echo " security-scan Run dependency vulnerability audit"
@echo " security-tests Run orchestrated security test suite"
@echo ""
@echo "🧪 Testing:"
@echo " test-telemetry Run all telemetry tests"
@echo " test-telemetry-null Run NullTelemetryService tests"
@echo " test-telemetry-real Run RealTelemetryService tests"
@echo " test-telemetry-config Run OTLP configuration tests"
@echo " test-telemetry-factory Run TelemetryFactory tests"
@echo " test-telemetry-di Run Dependency Injection integration tests"
@echo " test-telemetry-integration Run telemetry integration tests"
@echo " test-telemetry-profiles Run telemetry profiles tests"
@echo " test-telemetry-attribute-groups Run AttributeGroupManager tests"
@echo " test-telemetry-filtering Run attribute filtering tests"
@echo " test-telemetry-monolog Run Monolog integration tests"
@echo " test-telemetry-monolog-e2e Run E2E Monolog test (requires b24-ai-starter-otel)"
@echo " test-telemetry-profiles-e2e Run E2E profile filtering test (requires b24-ai-starter-otel)"
@echo " test-telemetry-e2e Run E2E tests (requires b24-ai-starter-otel)"
@echo " test-telemetry-app-events Run all application integration point tests"
@echo " test-telemetry-app-lifecycle Run app install/uninstall lifecycle tests"
@echo " test-telemetry-ui-events Run UI events and session context trait tests"
@echo " test-telemetry-action-events Run B24 event handler action tracking tests"
@echo " test-telemetry-api-calls Run Bitrix24 API call tracking tests"
@echo " test-telemetry-error-tracking Run exception listener error tracking tests"
@echo " test-telemetry-session-context Run session ID propagation tests"
@echo " test-telemetry-frontend-events Run frontend telemetry endpoint tests (Sprint 8)"
@echo " test-telemetry-frontend-e2e Run frontend telemetry full-flow E2E test (requires b24-ai-starter-otel)"
@echo ""
@echo "💡 Quick start: make dev-init"
@echo ""
.DEFAULT_GOAL := help
# Initialization
dev-init:
@echo "🚀 Initializing Bitrix24 AI Starter project..."
@./scripts/dev-init.sh
create-version:
@echo "📂 Creating a new project version..."
@./scripts/create-version.sh $(VERSION)
delete-version:
@echo "🗑 Removing a project version..."
@./scripts/delete-version.sh $(VERSION)
fix-php:
@echo "🔧 Fixing PHP backend dependencies..."
@./scripts/fix-php.sh
# Development
dev-front:
@echo "Starting frontend"
COMPOSE_PROFILES=frontend,cloudpub $(DOCKER_COMPOSE) --env-file .env up --build
## PHP
dev-php:
@echo "Starting dev php"
@DB_TYPE_VALUE=$$(grep -E '^DB_TYPE=' .env 2>/dev/null | tail -n1 | cut -d= -f2); \
if [ -z "$$DB_TYPE_VALUE" ]; then DB_TYPE_VALUE=postgresql; fi; \
if [ "$$DB_TYPE_VALUE" = "mysql" ]; then DB_PROFILE="db-mysql"; else DB_PROFILE="db-postgres"; fi; \
ENABLE_RABBITMQ_VALUE=$$(grep -E '^ENABLE_RABBITMQ=' .env 2>/dev/null | tail -n1 | cut -d= -f2); \
if [ -z "$$ENABLE_RABBITMQ_VALUE" ]; then ENABLE_RABBITMQ_VALUE=0; fi; \
if [ "$$ENABLE_RABBITMQ_VALUE" = "1" ]; then \
PROFILES="php,cloudpub,queue,$$DB_PROFILE"; \
else \
PROFILES="php,cloudpub,$$DB_PROFILE"; \
fi; \
COMPOSE_PROFILES=$$PROFILES $(DOCKER_COMPOSE) --env-file .env up --build
# work with composer
.PHONY: composer-install
composer-install:
COMPOSE_PROFILES=php-cli $(DOCKER_COMPOSE) run --rm --user $(CURRENT_UID) --workdir /var/www php-cli composer install
.PHONY: composer-update
composer-update:
COMPOSE_PROFILES=php-cli $(DOCKER_COMPOSE) run --rm --user $(CURRENT_UID) --workdir /var/www php-cli composer update
.PHONY: composer-dumpautoload
composer-dumpautoload:
COMPOSE_PROFILES=php-cli $(DOCKER_COMPOSE) run --rm --user $(CURRENT_UID) --workdir /var/www php-cli composer dumpautoload
# call composer with any parameters
# make composer install
# make composer "install --no-dev"
# make composer require symfony/http-client
.PHONY: composer
composer:
COMPOSE_PROFILES=php-cli $(DOCKER_COMPOSE) run --rm --user $(CURRENT_UID) --workdir /var/www php-cli composer $(filter-out $@,$(MAKECMDGOALS))
.PHONY: php-cli-sh
php-cli-sh:
COMPOSE_PROFILES=php-cli $(DOCKER_COMPOSE) run --rm --user $(CURRENT_UID) --workdir /var/www php-cli sh
php-cli-app-example:
COMPOSE_PROFILES=php-cli $(DOCKER_COMPOSE) run --rm --workdir /var/www php-cli bin/console app:example
# linters
php-cli-lint-phpstan:
COMPOSE_PROFILES=php-cli $(DOCKER_COMPOSE) run --rm --workdir /var/www php-cli vendor/bin/phpstan --memory-limit=2G analyse -vvv
.PHONY: lint-rector
lint-rector:
COMPOSE_PROFILES=php-cli $(DOCKER_COMPOSE) run --rm --workdir /var/www php-cli vendor/bin/rector process --dry-run
.PHONY: lint-rector-fix
lint-rector-fix:
COMPOSE_PROFILES=php-cli $(DOCKER_COMPOSE) run --rm --workdir /var/www php-cli vendor/bin/rector process
.PHONY: lint-cs-fixer
lint-cs-fixer:
COMPOSE_PROFILES=php-cli $(DOCKER_COMPOSE) run --rm --workdir /var/www php-cli vendor/bin/php-cs-fixer check --verbose --diff
.PHONY: lint-cs-fixer-fix
lint-cs-fixer-fix:
COMPOSE_PROFILES=php-cli $(DOCKER_COMPOSE) run --rm --workdir /var/www php-cli vendor/bin/php-cs-fixer fix --verbose --diff
.PHONY: security-scan
security-scan:
@./scripts/security-scan.sh
.PHONY: security-tests
security-tests:
@./scripts/security-tests.sh $(SECURITY_TESTS_ARGS)
# Telemetry Testing
.PHONY: test-telemetry
test-telemetry: ## Run all telemetry tests
COMPOSE_PROFILES=php-cli $(DOCKER_COMPOSE) run --workdir /var/www php-cli vendor/bin/phpunit --configuration phpunit.xml.dist --testsuite telemetry-all
.PHONY: test-telemetry-null
test-telemetry-null: ## Run NullTelemetryService tests
COMPOSE_PROFILES=php-cli $(DOCKER_COMPOSE) run --workdir /var/www php-cli vendor/bin/phpunit --testsuite telemetry-null-service
.PHONY: test-telemetry-real
test-telemetry-real: ## Run RealTelemetryService tests
COMPOSE_PROFILES=php-cli $(DOCKER_COMPOSE) run --workdir /var/www php-cli vendor/bin/phpunit --testsuite telemetry-real-service
.PHONY: test-telemetry-config
test-telemetry-config: ## Run OTLP configuration tests
COMPOSE_PROFILES=php-cli $(DOCKER_COMPOSE) run --workdir /var/www php-cli vendor/bin/phpunit --testsuite telemetry-config
.PHONY: test-telemetry-factory
test-telemetry-factory: ## Run TelemetryFactory tests
COMPOSE_PROFILES=php-cli $(DOCKER_COMPOSE) run --workdir /var/www php-cli vendor/bin/phpunit --testsuite telemetry-factory
.PHONY: test-telemetry-di
test-telemetry-di: ## Run Dependency Injection integration tests
COMPOSE_PROFILES=php-cli $(DOCKER_COMPOSE) run --workdir /var/www php-cli vendor/bin/phpunit --testsuite telemetry-di
.PHONY: test-telemetry-integration
test-telemetry-integration: ## Run telemetry integration tests
COMPOSE_PROFILES=php-cli $(DOCKER_COMPOSE) run --workdir /var/www php-cli vendor/bin/phpunit --testsuite telemetry-integration
.PHONY: test-telemetry-profiles
test-telemetry-profiles: ## Run telemetry profiles tests
COMPOSE_PROFILES=php-cli $(DOCKER_COMPOSE) run --workdir /var/www php-cli vendor/bin/phpunit --testsuite telemetry-profiles
.PHONY: test-telemetry-attribute-groups
test-telemetry-attribute-groups: ## Run AttributeGroupManager tests
COMPOSE_PROFILES=php-cli $(DOCKER_COMPOSE) run --workdir /var/www php-cli vendor/bin/phpunit --testsuite telemetry-attribute-groups
.PHONY: test-telemetry-filtering
test-telemetry-filtering: ## Run attribute filtering tests
COMPOSE_PROFILES=php-cli $(DOCKER_COMPOSE) run --workdir /var/www php-cli vendor/bin/phpunit --testsuite telemetry-filtering
.PHONY: test-telemetry-monolog
test-telemetry-monolog: ## Run Monolog integration tests
COMPOSE_PROFILES=php-cli $(DOCKER_COMPOSE) run --workdir /var/www php-cli vendor/bin/phpunit --testsuite telemetry-monolog
.PHONY: test-telemetry-monolog-e2e
test-telemetry-monolog-e2e: ## Run E2E Monolog test (requires b24-ai-starter-otel running)
@echo "🚀 Checking b24-ai-starter-otel infrastructure..."
@cd ../b24-ai-starter-otel && $(DOCKER_COMPOSE) ps | grep -q "Up" || (echo "❌ b24-ai-starter-otel not running. Start with: cd ../b24-ai-starter-otel && make start" && exit 1)
@echo "✓ Infrastructure is running"
@echo ""
COMPOSE_PROFILES=php-cli $(DOCKER_COMPOSE) run -e TELEMETRY_ENABLED=true --workdir /var/www php-cli php bin/test-monolog-e2e.php
.PHONY: test-telemetry-profiles-e2e
test-telemetry-profiles-e2e: ## Run E2E profile filtering test (requires b24-ai-starter-otel running)
@echo "🚀 Checking b24-ai-starter-otel infrastructure..."
@cd ../b24-ai-starter-otel && $(DOCKER_COMPOSE) ps | grep -q "Up" || (echo "❌ b24-ai-starter-otel not running. Start with: cd ../b24-ai-starter-otel && make start" && exit 1)
@echo "✓ Infrastructure is running"
@echo ""
@echo "🧪 Running E2E Profile Filtering Test..."
@echo " Profile: simple-ui (Lifecycle + UI only)"
@echo ""
COMPOSE_PROFILES=php-cli $(DOCKER_COMPOSE) run -e TELEMETRY_ENABLED=true --workdir /var/www php-cli php bin/test-profile-filtering.php
.PHONY: test-telemetry-e2e
test-telemetry-e2e: ## Run end-to-end telemetry tests (requires b24-ai-starter-otel running)
@echo "🚀 Running E2E Telemetry Test"
@cd backends/php && ./tests/Telemetry/E2E/run-e2e-test.sh
.PHONY: test-telemetry-app-events
test-telemetry-app-events: ## Run all application integration point tests
COMPOSE_PROFILES=php-cli $(DOCKER_COMPOSE) run --workdir /var/www php-cli vendor/bin/phpunit --testsuite telemetry-app-events
.PHONY: test-telemetry-app-lifecycle
test-telemetry-app-lifecycle: ## Run app install/uninstall lifecycle tests
COMPOSE_PROFILES=php-cli $(DOCKER_COMPOSE) run --workdir /var/www php-cli vendor/bin/phpunit --testsuite telemetry-app-lifecycle
.PHONY: test-telemetry-ui-events
test-telemetry-ui-events: ## Run UI events and session context trait tests
COMPOSE_PROFILES=php-cli $(DOCKER_COMPOSE) run --workdir /var/www php-cli vendor/bin/phpunit --testsuite telemetry-ui-events
.PHONY: test-telemetry-action-events
test-telemetry-action-events: ## Run B24 event handler action tracking tests
COMPOSE_PROFILES=php-cli $(DOCKER_COMPOSE) run --workdir /var/www php-cli vendor/bin/phpunit --testsuite telemetry-action-events
.PHONY: test-telemetry-api-calls
test-telemetry-api-calls: ## Run Bitrix24 API call tracking tests
COMPOSE_PROFILES=php-cli $(DOCKER_COMPOSE) run --workdir /var/www php-cli vendor/bin/phpunit --testsuite telemetry-api-calls
.PHONY: test-telemetry-error-tracking
test-telemetry-error-tracking: ## Run exception listener error tracking tests
COMPOSE_PROFILES=php-cli $(DOCKER_COMPOSE) run --workdir /var/www php-cli vendor/bin/phpunit --testsuite telemetry-error-tracking
.PHONY: test-telemetry-session-context
test-telemetry-session-context: ## Run session ID propagation tests
COMPOSE_PROFILES=php-cli $(DOCKER_COMPOSE) run --workdir /var/www php-cli vendor/bin/phpunit --testsuite telemetry-session-context
.PHONY: test-telemetry-frontend-events
test-telemetry-frontend-events: ## Run frontend telemetry endpoint tests (DTO unit + controller WebTest)
COMPOSE_PROFILES=php-cli $(DOCKER_COMPOSE) run --workdir /var/www php-cli vendor/bin/phpunit --testsuite telemetry-frontend-events
.PHONY: test-telemetry-frontend-e2e
test-telemetry-frontend-e2e: ## Run frontend telemetry full-flow E2E test (requires b24-ai-starter-otel running)
@echo "Убедитесь что b24-ai-starter-otel запущен: cd ../b24-ai-starter-otel && make up"
COMPOSE_PROFILES=php-cli $(DOCKER_COMPOSE) run \
-e TELEMETRY_ENABLED=true \
-e OTEL_EXPORTER_OTLP_ENDPOINT=http://host.docker.internal:4318 \
-e CLICKHOUSE_USER=$${CLICKHOUSE_USER:-telemetry_user} \
-e CLICKHOUSE_PASSWORD=$${CLICKHOUSE_PASSWORD:-changeme_secure_password} \
--workdir /var/www php-cli vendor/bin/phpunit --testsuite telemetry-frontend-e2e
# Doctrine/Symfony database commands
# ATTENTION!
# This command drop database and create new database with empty structure with default tables
# You must call this command only for new project!
.PHONY: dev-php-init-database
dev-php-init-database: dev-php-db-drop dev-php-db-create dev-php-db-migrate
.PHONY: dev-php-db-create dev-php-db-drop dev-php-db-migrate dev-php-db-migrate-create dev-php-db-schema-update dev-php-db-schema-validate
dev-php-db-create:
@DB_TYPE_VALUE=$$(grep -E '^DB_TYPE=' .env 2>/dev/null | tail -n1 | cut -d= -f2); \
if [ -z "$$DB_TYPE_VALUE" ]; then DB_TYPE_VALUE=postgresql; fi; \
if [ "$$DB_TYPE_VALUE" = "mysql" ]; then DB_PROFILE="db-mysql"; else DB_PROFILE="db-postgres"; fi; \
COMPOSE_PROFILES=php-cli,$$DB_PROFILE $(DOCKER_COMPOSE) run --rm --workdir /var/www php-cli php bin/console doctrine:database:create --if-not-exists
dev-php-db-drop:
@DB_TYPE_VALUE=$$(grep -E '^DB_TYPE=' .env 2>/dev/null | tail -n1 | cut -d= -f2); \
if [ -z "$$DB_TYPE_VALUE" ]; then DB_TYPE_VALUE=postgresql; fi; \
if [ "$$DB_TYPE_VALUE" = "mysql" ]; then DB_PROFILE="db-mysql"; else DB_PROFILE="db-postgres"; fi; \
COMPOSE_PROFILES=php-cli,$$DB_PROFILE $(DOCKER_COMPOSE) run --rm --workdir /var/www php-cli php bin/console doctrine:database:drop --force --if-exists
dev-php-db-migrate:
@DB_TYPE_VALUE=$$(grep -E '^DB_TYPE=' .env 2>/dev/null | tail -n1 | cut -d= -f2); \
if [ -z "$$DB_TYPE_VALUE" ]; then DB_TYPE_VALUE=postgresql; fi; \
if [ "$$DB_TYPE_VALUE" = "mysql" ]; then DB_PROFILE="db-mysql"; else DB_PROFILE="db-postgres"; fi; \
COMPOSE_PROFILES=php-cli,$$DB_PROFILE $(DOCKER_COMPOSE) run --rm --workdir /var/www php-cli php bin/console doctrine:migrations:migrate --no-interaction
dev-php-db-migrate-create:
@DB_TYPE_VALUE=$$(grep -E '^DB_TYPE=' .env 2>/dev/null | tail -n1 | cut -d= -f2); \
if [ -z "$$DB_TYPE_VALUE" ]; then DB_TYPE_VALUE=postgresql; fi; \
if [ "$$DB_TYPE_VALUE" = "mysql" ]; then DB_PROFILE="db-mysql"; else DB_PROFILE="db-postgres"; fi; \
COMPOSE_PROFILES=php-cli,$$DB_PROFILE $(DOCKER_COMPOSE) run --rm --workdir /var/www php-cli php bin/console make:migration --no-interaction
dev-php-db-migrate-status:
@DB_TYPE_VALUE=$$(grep -E '^DB_TYPE=' .env 2>/dev/null | tail -n1 | cut -d= -f2); \
if [ -z "$$DB_TYPE_VALUE" ]; then DB_TYPE_VALUE=postgresql; fi; \
if [ "$$DB_TYPE_VALUE" = "mysql" ]; then DB_PROFILE="db-mysql"; else DB_PROFILE="db-postgres"; fi; \
COMPOSE_PROFILES=php-cli,$$DB_PROFILE $(DOCKER_COMPOSE) run --rm --workdir /var/www php-cli php bin/console doctrine:migrations:status
dev-php-db-schema-update:
@DB_TYPE_VALUE=$$(grep -E '^DB_TYPE=' .env 2>/dev/null | tail -n1 | cut -d= -f2); \
if [ -z "$$DB_TYPE_VALUE" ]; then DB_TYPE_VALUE=postgresql; fi; \
if [ "$$DB_TYPE_VALUE" = "mysql" ]; then DB_PROFILE="db-mysql"; else DB_PROFILE="db-postgres"; fi; \
COMPOSE_PROFILES=php-cli,$$DB_PROFILE $(DOCKER_COMPOSE) run --rm --workdir /var/www php-cli php bin/console doctrine:schema:update --force
dev-php-db-schema-validate:
@DB_TYPE_VALUE=$$(grep -E '^DB_TYPE=' .env 2>/dev/null | tail -n1 | cut -d= -f2); \
if [ -z "$$DB_TYPE_VALUE" ]; then DB_TYPE_VALUE=postgresql; fi; \
if [ "$$DB_TYPE_VALUE" = "mysql" ]; then DB_PROFILE="db-mysql"; else DB_PROFILE="db-postgres"; fi; \
COMPOSE_PROFILES=php-cli,$$DB_PROFILE $(DOCKER_COMPOSE) run --rm --workdir /var/www php-cli php bin/console doctrine:schema:validate
## Python
dev-python:
@echo "Starting dev python"
@DB_TYPE_VALUE=$$(grep -E '^DB_TYPE=' .env 2>/dev/null | tail -n1 | cut -d= -f2); \
if [ -z "$$DB_TYPE_VALUE" ]; then DB_TYPE_VALUE=postgresql; fi; \
if [ "$$DB_TYPE_VALUE" = "mysql" ]; then DB_PROFILE="db-mysql"; else DB_PROFILE="db-postgres"; fi; \
ENABLE_RABBITMQ_VALUE=$$(grep -E '^ENABLE_RABBITMQ=' .env 2>/dev/null | tail -n1 | cut -d= -f2); \
if [ -z "$$ENABLE_RABBITMQ_VALUE" ]; then ENABLE_RABBITMQ_VALUE=0; fi; \
if [ "$$ENABLE_RABBITMQ_VALUE" = "1" ]; then \
PROFILES="frontend,python,cloudpub,queue,$$DB_PROFILE"; \
else \
PROFILES="frontend,python,cloudpub,$$DB_PROFILE"; \
fi; \
COMPOSE_PROFILES=$$PROFILES $(DOCKER_COMPOSE) --env-file .env up --build
## NodeJs
dev-node:
@echo "Starting dev node"
@DB_TYPE_VALUE=$$(grep -E '^DB_TYPE=' .env 2>/dev/null | tail -n1 | cut -d= -f2); \
if [ -z "$$DB_TYPE_VALUE" ]; then DB_TYPE_VALUE=postgresql; fi; \
if [ "$$DB_TYPE_VALUE" = "mysql" ]; then DB_PROFILE="db-mysql"; else DB_PROFILE="db-postgres"; fi; \
ENABLE_RABBITMQ_VALUE=$$(grep -E '^ENABLE_RABBITMQ=' .env 2>/dev/null | tail -n1 | cut -d= -f2); \
if [ -z "$$ENABLE_RABBITMQ_VALUE" ]; then ENABLE_RABBITMQ_VALUE=0; fi; \
if [ "$$ENABLE_RABBITMQ_VALUE" = "1" ]; then \
PROFILES="frontend,node,cloudpub,queue,$$DB_PROFILE"; \
else \
PROFILES="frontend,node,cloudpub,$$DB_PROFILE"; \
fi; \
COMPOSE_PROFILES=$$PROFILES $(DOCKER_COMPOSE) --env-file .env up --build
# Production
prod-php:
@echo "Starting prod php environment"
COMPOSE_PROFILES=php FRONTEND_TARGET=production $(DOCKER_COMPOSE) up --build -d
prod-python:
@echo "Starting prod python environment"
COMPOSE_PROFILES=python FRONTEND_TARGET=production $(DOCKER_COMPOSE) up --build -d
prod-node:
@echo "Starting prod node environment"
COMPOSE_PROFILES=node FRONTEND_TARGET=production $(DOCKER_COMPOSE) up --build -d
# Utils
status:
docker stats
ps:
watch -n 2 docker ps
down:
@echo "🛑 Останавливаем все контейнеры..."
COMPOSE_PROFILES=frontend,php,python,node,cloudpub,queue $(DOCKER_COMPOSE) down --remove-orphans || true
docker container stop $$(docker container ls -q --filter "name=b24" --filter "name=frontend" --filter "name=api" --filter "name=cloudpub") 2>/dev/null || true
queue-up:
@echo "▶️ Запускаем только RabbitMQ"
@ENABLE_RABBITMQ_VALUE=$$(grep -E '^ENABLE_RABBITMQ=' .env 2>/dev/null | tail -n1 | cut -d= -f2); \
if [ -z "$$ENABLE_RABBITMQ_VALUE" ]; then ENABLE_RABBITMQ_VALUE=0; fi; \
if [ "$$ENABLE_RABBITMQ_VALUE" != "1" ]; then \
echo "⚠️ ENABLE_RABBITMQ=0 в .env — сервис запустится, но переменные стоит обновить"; \
fi; \
COMPOSE_PROFILES=queue $(DOCKER_COMPOSE) --env-file .env up rabbitmq --build -d
queue-down:
@echo "⏹ Останавливаем только RabbitMQ"
COMPOSE_PROFILES=queue $(DOCKER_COMPOSE) --env-file .env stop rabbitmq || true
down-all:
$(DOCKER_COMPOSE) down --remove-orphans
$(DOCKER_COMPOSE) -f docker-compose.server.yml down --remove-orphans
clean:
@echo "🧹 Полная очистка Docker окружения..."
$(DOCKER_COMPOSE) down --remove-orphans --volumes || true
docker container rm -f $$(docker container ls -aq --filter "name=b24") 2>/dev/null || true
docker network prune -f
docker volume prune -f
@echo "✓ Очистка завершена"
logs:
$(DOCKER_COMPOSE) logs -f
logs-nginxproxy:
$(DOCKER_COMPOSE) logs -f docker-compose.server.yml
# Database operations
db-backup:
@DB_TYPE_VALUE=$$(grep -E '^DB_TYPE=' .env 2>/dev/null | tail -n1 | cut -d= -f2); \
if [ -z "$$DB_TYPE_VALUE" ]; then DB_TYPE_VALUE=postgresql; fi; \
if [ "$$DB_TYPE_VALUE" = "mysql" ]; then \
COMPOSE_PROFILES=db-mysql $(DOCKER_COMPOSE) exec -T database-mysql sh -lc "exec mysqldump -u\"$${DB_USER:-appuser}\" -p\"$${DB_PASSWORD:-apppass}\" \"$${DB_NAME:-appdb}\"" > backup_$(shell date +%Y%m%d_%H%M%S).sql; \
else \
COMPOSE_PROFILES=db-postgres $(DOCKER_COMPOSE) exec -T database-postgres pg_dump -U $${DB_USER:-appuser} $${DB_NAME:-appdb} > backup_$(shell date +%Y%m%d_%H%M%S).sql; \
fi
db-restore:
@DB_TYPE_VALUE=$$(grep -E '^DB_TYPE=' .env 2>/dev/null | tail -n1 | cut -d= -f2); \
if [ -z "$$DB_TYPE_VALUE" ]; then DB_TYPE_VALUE=postgresql; fi; \
if [ "$$DB_TYPE_VALUE" = "mysql" ]; then \
COMPOSE_PROFILES=db-mysql $(DOCKER_COMPOSE) exec -T database-mysql sh -lc "exec mysql -u\"$${DB_USER:-appuser}\" -p\"$${DB_PASSWORD:-apppass}\" \"$${DB_NAME:-appdb}\"" < $(file); \
else \
COMPOSE_PROFILES=db-postgres $(DOCKER_COMPOSE) exec -T database-postgres psql -U $${DB_USER:-appuser} $${DB_NAME:-appdb} < $(file); \
fi