-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
120 lines (98 loc) · 3 KB
/
Makefile
File metadata and controls
120 lines (98 loc) · 3 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
SHELL := /usr/bin/env bash
.ONESHELL:
.DEFAULT_GOAL := help
# ==== Paths ====
COMPOSE_BASE := infra/compose/compose.yml
COMPOSE_LOCAL := infra/compose/compose.local.yml
COMPOSE_DEV := infra/compose/stack.dev.yml
COMPOSE_PROD := infra/compose/stack.prod.yml
TRAEFIK_STACK := infra/compose/stack.traefik.yml
# ==== Envs ====
ENV_FILE ?= .env
# ==== Helpers ====
define source_env
set -euo pipefail; \
if [[ -f $(1) ]]; then \
set -a; source $(1); set +a; \
else \
echo "ENV file $(1) not found"; exit 1; \
fi
endef
# ==== Help ====
help: ## Показать цели Makefile
@grep -E '^[a-zA-Z0-9_-]+:.*?## ' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-18s\033[0m %s\n", $$1, $$2}'
# Export all variables from .env file
ifneq (,$(wildcard ./.env))
include .env
export
endif
# ==== Commands ====
up:
docker compose \
--env-file $(ENV_FILE) \
-f $(COMPOSE_BASE) \
-f $(COMPOSE_PROD) \
up -d
up-dev:
docker compose \
--env-file $(ENV_FILE) \
-f $(COMPOSE_BASE) \
-f $(COMPOSE_DEV) \
up -d
up-local:
docker compose \
--env-file $(ENV_FILE) \
-f $(COMPOSE_BASE) \
-f $(COMPOSE_LOCAL) \
up -d
down:
docker-compose \
--env-file $(ENV_FILE) \
-f $(COMPOSE_BASE) \
-f $(COMPOSE_PROD) \
down
down-dev:
docker-compose \
--env-file $(ENV_FILE) \
-f $(COMPOSE_BASE) \
-f $(COMPOSE_DEV) \
down
down-local:
docker compose \
--env-file $(ENV_FILE) \
-f $(COMPOSE_BASE) \
-f $(COMPOSE_LOCAL) \
down
deploy-dev:
. $(ENV_FILE); docker stack deploy \
-c $(COMPOSE_BASE) \
-c $(COMPOSE_DEV) \
--with-registry-auth app-dev
build: ## Пересобрать контейнеры (production)
docker-compose --env-file .env -f infra/compose/compose.yml build
build-dev: ## Пересобрать контейнеры (dev mode)
docker-compose --env-file .env -f infra/compose/compose.yml -f compose.override.yml build
logs: ## Хвост логов backend + frontend (production)
docker-compose --env-file .env -f infra/compose/compose.yml logs -f backend frontend
logs-dev: ## Хвост логов backend + frontend (dev mode)
docker-compose --env-file .env -f infra/compose/compose.yml -f compose.override.yml logs -f backend frontend
status:
@echo "=== Running Containers ==="
@docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
@echo ""
@echo "=== All Project Containers ==="
@docker compose \
--env-file $(ENV_FILE) \
-f $(COMPOSE_BASE) \
-f $(COMPOSE_LOCAL) \
ps
clean: ## Полный reset окружения
docker-compose --env-file .env -f infra/compose/compose.yml -f compose.override.yml down -v --remove-orphans
docker system prune -f
test: ## Локально прогнать тесты в контейнерах
docker-compose -f infra/compose/compose.yml \
-f infra/compose/compose.test.yml \
up --build --abort-on-container-exit --exit-code-from backend
ts-client:
poetry run python -m scripts.generate_ts_client --url http://localhost:8000/openapi.json
.PHONY: ts-client