-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
71 lines (50 loc) · 2.62 KB
/
Copy pathMakefile
File metadata and controls
71 lines (50 loc) · 2.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
# Root Makefile: every routine command in one place. `make help` lists them.
SERVICES := app
MIGRATE := migrate
DB_URL ?= mysql://lynk:lynk@tcp(127.0.0.1:3307)/app_db
.PHONY: help build vet lint fmt generate \
dev dev-worker \
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 sqlc code
cd services/app && sqlc generate
# Hot reload (install: go install github.com/air-verse/air@latest)
dev: ## Hot-reload the REST API server
cd services/app && air
dev-worker: ## Hot-reload the worker
cd services/app && air -c .air.worker.toml
# Database ergonomics (golang-migrate; install with:
# go install -tags 'mysql,file' github.com/golang-migrate/migrate/v4/cmd/migrate@latest)
migrate-up: ## Apply pending migrations
$(MIGRATE) -path services/app/migrations -database "$(DB_URL)" up
migrate-down: ## Roll back ONE migration
$(MIGRATE) -path services/app/migrations -database "$(DB_URL)" down 1
migrate-status: ## Show current migration version
$(MIGRATE) -path services/app/migrations -database "$(DB_URL)" version
migrate-create: ## Create a migration pair: make migrate-create NAME=add_x
$(MIGRATE) create -ext sql -dir services/app/migrations -seq $(NAME)
db-fresh: ## Drop everything and re-apply all migrations (DESTRUCTIVE, dev only)
$(MIGRATE) -path services/app/migrations -database "$(DB_URL)" drop -f
$(MIGRATE) -path services/app/migrations -database "$(DB_URL)" up
db-seed: ## Create the development admin account (idempotent)
cd services/app && go run ./cmd/seed
infra-up: ## Start mysql + redis + nats only
cd deploy && docker compose up -d mysql redis nats
infra-down: ## Stop the infrastructure containers
cd deploy && docker compose stop mysql 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