-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
184 lines (148 loc) · 6.56 KB
/
Makefile
File metadata and controls
184 lines (148 loc) · 6.56 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
# sico -- Makefile
.PHONY: help setup setup-check setup-kind setup-kind-check lint lint-fix license-check precommit-run precommit-update
.PHONY: openapi unzip-frontend
.PHONY: compose-up compose-down compose-logs
.PHONY: kind-up kind-stop kind-down kind-restart
.PHONY: emulator-setup emulator-start emulator-stop emulator-restart emulator-status emulator-logs
.PHONY: emulator-bootstrap emulator-stop-devices
# Detect platform so we can dispatch to the right installer script.
ifeq ($(OS),Windows_NT)
INSTALL_CMD := powershell -ExecutionPolicy Bypass -File scripts/install-dev-tools.ps1
INSTALL_KIND_CMD := powershell -ExecutionPolicy Bypass -File scripts/install-dev-tools.ps1 -WithHelm
else
INSTALL_CMD := bash scripts/install-dev-tools.sh
INSTALL_KIND_CMD := bash scripts/install-dev-tools.sh --with-helm
endif
help:
@echo ""
@echo "sico"
@echo "===="
@echo ""
@echo "Developer setup:"
@echo " make setup Install default toolchain + git hooks (macOS/Linux/Windows)"
@echo " make setup-check Verify the default toolchain is installed"
@echo " make setup-kind Install default toolchain + Helm/kubectl/kind for Kind work"
@echo " make setup-kind-check Verify the Kind toolchain (Helm + kubectl + kind) is installed"
@echo " make precommit-run Run all pre-commit hooks against the whole tree"
@echo " make precommit-update Update pinned hook versions in .pre-commit-config.yaml"
@echo " make lint Run repository-wide lint checks"
@echo " make lint-fix Run lints with auto-fixes where supported"
@echo " make license-check Verify every source file has a MIT license header"
@echo " make openapi Regenerate backend swagger docs (api/openapi)"
@echo " make unzip-frontend Unzip frontend-dist.zip for local development"
@echo ""
@echo "Docker Compose (local):"
@echo " make compose-up Build and start full stack"
@echo " make compose-up SERVICE=core Rebuild/recreate one service image"
@echo " make compose-down Stop and remove containers"
@echo " make compose-logs Tail logs"
@echo ""
@echo "Kind (local Kubernetes):"
@echo " make kind-up Create Kind cluster and deploy everything"
@echo " make kind-stop Stop Kind containers without deleting data"
@echo " make kind-down Tear down Kind cluster"
@echo " make kind-restart SVC=xxx Rebuild and roll out one app service image"
@echo ""
@echo "Emulator service (macOS / Windows host only):"
@echo " make emulator-setup Install prereqs and start API service"
@echo " make emulator-start Start the emulator API service only"
@echo " make emulator-stop Stop the emulator API service only"
@echo " make emulator-restart Restart the emulator API service only"
@echo " make emulator-status Show the emulator API service status"
@echo " make emulator-bootstrap Bootstrap default device; requires API service"
@echo " make emulator-stop-devices Stop all running emulator devices"
@echo " make emulator-logs Tail the emulator API service log"
@echo ""
# -- Developer setup ---------------------------------------------------------
setup:
$(INSTALL_CMD)
setup-check:
ifeq ($(OS),Windows_NT)
powershell -ExecutionPolicy Bypass -File scripts/install-dev-tools.ps1 -Check
else
bash scripts/install-dev-tools.sh --check
endif
setup-kind:
$(INSTALL_KIND_CMD)
setup-kind-check:
ifeq ($(OS),Windows_NT)
powershell -ExecutionPolicy Bypass -File scripts/install-dev-tools.ps1 -Check -WithHelm
else
bash scripts/install-dev-tools.sh --check --with-helm
endif
precommit-run:
pre-commit run --all-files
precommit-update:
pre-commit autoupdate
lint:
@bash scripts/lint.sh
lint-fix:
@bash scripts/lint.sh --fix
license-check:
pre-commit run addlicense --all-files
# -- OpenAPI (swagger) --------------------------------------------------------
# Regenerate backend/api/openapi/* from swag annotations.
# The same command is invoked by scripts/lint.sh and CI, so all three paths
# stay aligned.
openapi:
@command -v swag >/dev/null 2>&1 || { \
echo "swag not found. Install: go install github.com/swaggo/swag/cmd/swag@latest"; \
exit 1; }
cd backend && swag init -g cmd/sico-server/main.go --parseDependency --parseInternal -o api/openapi
# -- Frontend dist (for local development) ------------------------------------
# Unzip pre-built frontend assets so the backend can serve them locally.
unzip-frontend:
ifeq ($(OS),Windows_NT)
@powershell -NoProfile -ExecutionPolicy Bypass -Command "Remove-Item -Recurse -Force 'frontend-dist' -ErrorAction SilentlyContinue; New-Item -ItemType Directory -Force 'frontend-dist' | Out-Null; Expand-Archive -Path 'frontend/frontend-dist.zip' -DestinationPath 'frontend-dist' -Force"
else
@rm -rf frontend-dist
@mkdir -p frontend-dist
unzip -q frontend/frontend-dist.zip -d frontend-dist
endif
@echo "frontend-dist/ ready"
# -- Docker Compose -----------------------------------------------------------
COMPOSE := docker compose -p sico -f deploy/docker/docker-compose.yaml --env-file .env
compose-up:
$(COMPOSE) up --build -d $(SERVICE)
@echo ""
@port=$$(awk -F= '/^SICO_PORT=/{print $$2}' .env 2>/dev/null | tail -1 | tr -d '"' | tr -d "'"); \
port=$${port:-8080}; \
echo "sico is running!"; \
echo " Home: http://localhost:$${port}/"; \
echo " UI login: http://localhost:$${port}/login"; \
echo " API docs: http://localhost:$${port}/api/sico/docs/index.html"; \
echo " Health: http://localhost:$${port}/api/sico/health"
compose-down:
$(COMPOSE) down --remove-orphans
compose-logs:
$(COMPOSE) logs -f
# -- Kind ---------------------------------------------------------------------
kind-up:
bash deploy/kind/setup.sh up
kind-stop:
bash deploy/kind/setup.sh stop
kind-down:
bash deploy/kind/setup.sh down
kind-restart:
bash deploy/kind/setup.sh restart "$(SVC)"
# -- Emulator service ---------------------------------------------------------
# The emulator service runs directly on the host (macOS or Windows via Git
# Bash) because it depends on a GUI Android emulator backend (Android Studio
# AVD or MuMu Player). It is not containerized.
EMULATOR_SETUP := bash sandbox/emulator/setup/setup.sh
emulator-setup:
$(EMULATOR_SETUP) install
emulator-start:
$(EMULATOR_SETUP) start
emulator-stop:
$(EMULATOR_SETUP) stop
emulator-restart:
$(EMULATOR_SETUP) restart
emulator-status:
$(EMULATOR_SETUP) status
emulator-bootstrap:
$(EMULATOR_SETUP) bootstrap
emulator-stop-devices:
$(EMULATOR_SETUP) stop-devices
emulator-logs:
$(EMULATOR_SETUP) logs