-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
75 lines (53 loc) · 2.91 KB
/
Copy pathMakefile
File metadata and controls
75 lines (53 loc) · 2.91 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
# Root Makefile: every routine command in one place. `make help` lists them.
# Services are independent Go modules; loops run the same target in each.
SERVICES := core gateway
MIGRATE := migrate
DB_URL ?= postgres://lynk:lynk@127.0.0.1:5433/core_db?sslmode=disable
.PHONY: help build vet lint fmt generate \
dev-core dev-core-worker dev-gateway \
migrate-up migrate-down migrate-status migrate-create db-fresh db-seed \
infra-up infra-down stack-up stack-down hooks
help: ## List available targets
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " %-16s %s\n", $$1, $$2}'
build: ## Build every service
@for s in $(SERVICES); do echo "== build $$s"; (cd services/$$s && go build ./...) || exit 1; done
vet: ## Vet every service
@for s in $(SERVICES); do echo "== vet $$s"; (cd services/$$s && go vet ./...) || exit 1; done
lint: ## Lint every service (golangci-lint v2)
@for s in $(SERVICES); do echo "== lint $$s"; (cd services/$$s && golangci-lint run ./...) || exit 1; done
fmt: ## gofmt every service
@for s in $(SERVICES); do (cd services/$$s && gofmt -w .); done
generate: ## Regenerate protobuf + sqlc code (core)
cd services/core && buf generate && sqlc generate
# Hot reload (one terminal each; install: go install github.com/air-verse/air@latest)
dev-core: ## Hot-reload the core API server
cd services/core && air
dev-core-worker: ## Hot-reload the core worker
cd services/core && air -c .air.worker.toml
dev-gateway: ## Hot-reload the gateway
cd services/gateway && air
# Database ergonomics (golang-migrate; install with:
# go install -tags 'postgres,file' github.com/golang-migrate/migrate/v4/cmd/migrate@latest)
migrate-up: ## Apply pending core migrations
$(MIGRATE) -path services/core/migrations -database "$(DB_URL)" up
migrate-down: ## Roll back ONE core migration
$(MIGRATE) -path services/core/migrations -database "$(DB_URL)" down 1
migrate-status: ## Show current core migration version
$(MIGRATE) -path services/core/migrations -database "$(DB_URL)" version
migrate-create: ## Create a migration pair: make migrate-create NAME=add_x
$(MIGRATE) create -ext sql -dir services/core/migrations -seq $(NAME)
db-fresh: ## Drop everything and re-apply all migrations (DESTRUCTIVE, dev only)
$(MIGRATE) -path services/core/migrations -database "$(DB_URL)" drop -f
$(MIGRATE) -path services/core/migrations -database "$(DB_URL)" up
db-seed: ## Create the development admin account (idempotent)
cd services/core && go run ./cmd/seed
infra-up: ## Start postgres + redis + nats only
cd deploy && docker compose up -d postgres redis nats
infra-down: ## Stop the infrastructure containers
cd deploy && docker compose stop postgres redis nats
stack-up: ## Build and start the full stack
cd deploy && docker compose up -d --build
stack-down: ## Stop the full stack
cd deploy && docker compose down
hooks: ## Install the pre-commit hooks
pre-commit install