-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
147 lines (109 loc) · 6.52 KB
/
Makefile
File metadata and controls
147 lines (109 loc) · 6.52 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
# ── go-initializer Makefile ────────────────────────────────────────────────────
# Usage: make <target>
# Run `make help` for a list of available targets.
.DEFAULT_GOAL := help
BINARY_SERVER := bin/server
BINARY_CLI := bin/goini
# ── Help ───────────────────────────────────────────────────────────────────────
.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-22s\033[0m %s\n", $$1, $$2}'
# ── Go — dependencies ─────────────────────────────────────────────────────────
.PHONY: tidy
tidy: ## Tidy and verify Go module dependencies
go mod tidy
go mod verify
# ── Go — build ────────────────────────────────────────────────────────────────
.PHONY: build
build: build-server build-cli ## Build both the server and goini binaries
.PHONY: build-server
build-server: ## Build the HTTP server binary → bin/server
go build -o $(BINARY_SERVER) ./cmd/server/...
.PHONY: build-cli
build-cli: ## Build the goini CLI binary → bin/goini
go build -o $(BINARY_CLI) ./cmd/goini/...
# ── Go — run ──────────────────────────────────────────────────────────────────
.PHONY: run-server
run-server: ## Run the HTTP server (hot-reload not included; uses go run)
go run ./cmd/server/...
.PHONY: run-cli
run-cli: ## Run the goini CLI (pass ARGS="new --name foo" to forward flags)
go run ./cmd/goini/... $(ARGS)
# ── Go — test ─────────────────────────────────────────────────────────────────
.PHONY: test
test: ## Run all Go tests with race detector
go test -race ./...
.PHONY: test-verbose
test-verbose: ## Run all Go tests with verbose output
go test -race -v ./...
.PHONY: test-cover
test-cover: ## Run tests and show coverage report
go test -race -coverprofile=coverage.out ./...
go tool cover -html=coverage.out
# ── Go — lint / vet ───────────────────────────────────────────────────────────
.PHONY: vet
vet: ## Run go vet on all packages
go vet ./...
# ── Frontend ──────────────────────────────────────────────────────────────────
.PHONY: frontend-install
frontend-install: ## Install frontend npm dependencies
cd frontend && npm install
.PHONY: frontend-dev
frontend-dev: ## Start frontend Vite dev server (http://localhost:3000)
cd frontend && npm run start
.PHONY: frontend-build
frontend-build: ## Build frontend for production → frontend/dist/
cd frontend && npm run build
.PHONY: frontend-preview
frontend-preview: ## Preview the production frontend build locally
cd frontend && npm run preview
# ── Full stack (local, no Docker) ─────────────────────────────────────────────
.PHONY: dev
dev: ## Start backend server + frontend dev server concurrently
@trap 'kill 0' SIGINT; \
$(MAKE) run-server & \
$(MAKE) frontend-dev & \
wait
# ── Docker ────────────────────────────────────────────────────────────────────
.PHONY: docker-build
docker-build: ## Build all Docker images via docker-compose
docker compose build
.PHONY: docker-up
docker-up: ## Start all services via docker-compose (detached)
docker compose up -d
.PHONY: docker-down
docker-down: ## Stop and remove all docker-compose containers
docker compose down
.PHONY: docker-logs
docker-logs: ## Tail logs from all docker-compose services
docker compose logs -f
.PHONY: docker-restart
docker-restart: docker-down docker-up ## Rebuild images and restart all services
# ── Docker image digest pinning ───────────────────────────────────────────────
.PHONY: update-digests
update-digests: ## Re-resolve and print current sha256 digests for all pinned base images
@echo "=== golang:1.25.8-alpine ==="
@docker buildx imagetools inspect golang:1.25.8-alpine --format '{{json .Manifest}}' | python3 -c "import sys,json; print(json.load(sys.stdin)['digest'])"
@echo "=== alpine:latest ==="
@docker buildx imagetools inspect alpine:latest --format '{{json .Manifest}}' | python3 -c "import sys,json; print(json.load(sys.stdin)['digest'])"
@echo "=== node:22-alpine ==="
@docker buildx imagetools inspect node:22-alpine --format '{{json .Manifest}}' | python3 -c "import sys,json; print(json.load(sys.stdin)['digest'])"
@echo "=== nginx:stable-alpine ==="
@docker buildx imagetools inspect nginx:stable-alpine --format '{{json .Manifest}}' | python3 -c "import sys,json; print(json.load(sys.stdin)['digest'])"
@echo ""
@echo "Update FROM lines in cmd/server/Dockerfile and frontend/Dockerfile with the above digests."
# ── goini CLI helpers ─────────────────────────────────────────────────────────
.PHONY: install-cli
install-cli: ## Install goini CLI to GOPATH/bin via go install
go install ./cmd/goini/...
.PHONY: completions
completions: build-cli ## Generate shell completion scripts → completions/
mkdir -p completions
$(BINARY_CLI) completion bash > completions/goini.bash
$(BINARY_CLI) completion zsh > completions/goini.zsh
$(BINARY_CLI) completion fish > completions/goini.fish
# ── Clean ─────────────────────────────────────────────────────────────────────
.PHONY: clean
clean: ## Remove build artifacts
rm -rf bin/ coverage.out