Files
pwa-homelab-mon/Makefile
T

42 lines
1.9 KiB
Makefile
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
PORT ?= 8080 # порт бэка; в dev еще прокидывается в vite-прокси (BACKEND_PORT)
.PHONY: proto web server release dev dev-srv dev-web watch test
proto: ## Regenerate Go + TS code from proto
PATH="$(shell go env GOPATH)/bin:$$PATH" protoc \
--proto_path=proto \
--go_out=. --go_opt=module=pwa-homelab-mon \
--connect-go_out=. --connect-go_opt=module=pwa-homelab-mon \
--plugin=protoc-gen-es=web/node_modules/.bin/protoc-gen-es \
--es_out=web/src/gen --es_opt=target=ts \
proto/homelab/v1/homelab.proto
web: ## Build frontend into dist/ (tsc + vite) — same dir the binary serves
cd web && pnpm install --frozen-lockfile && pnpm build && rm -rf ../dist && cp -r dist ../dist
server: ## Build Go binary → bin/hub-api
go build -o bin/hub-api ./server
release: ## CI build: static binary for the box (run on the box itself, native arch)
CGO_ENABLED=0 go build -o bin/hub-api ./server
dev: ## Dev: Go server + Vite on :5173 (use http://localhost:5173); PORT=8081 make dev для второй копии
PORT=$(PORT) go run ./server & cd web && BACKEND_PORT=$(PORT) pnpm dev
dev-srv:
PORT=$(PORT) go run ./server
dev-web:
cd web && BACKEND_PORT=$(PORT) pnpm dev
watch: ## Hot-reload сервера (air); порт как у dev: PORT=8081 make watch
PORT=$(PORT) air
test: ## Smoke-test the RPC endpoints
@go build -o bin/hub-api ./server
@./bin/hub-api & sleep 1; \
curl -sf -X POST localhost:8080/homelab.v1.HomelabService/ListContent -H 'Content-Type: application/json' -d '{}' | grep -q '"cpu"' || exit 1; \
curl -sf -X POST localhost:8080/homelab.v1.HomelabService/ListDocs -H 'Content-Type: application/json' -d '{}' | grep -q 'test.md' || exit 1; \
curl -sf -X POST localhost:8080/homelab.v1.HomelabService/RunScript -H 'Content-Type: application/json' -d '{"name":"greet","args":["pony","42"]}' | grep -q 'arg1: pony' || exit 1; \
kill %1; echo OK