-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathMakefile
More file actions
82 lines (62 loc) · 3.35 KB
/
Copy pathMakefile
File metadata and controls
82 lines (62 loc) · 3.35 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
BINARY := miabi
PKG := github.com/miabi-io/miabi
VERSION ?= dev
COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
BUILD_DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
LDFLAGS := -X $(PKG)/internal/config.Version=$(VERSION) -X $(PKG)/internal/config.CommitID=$(COMMIT) -X $(PKG)/internal/config.BuildDate=$(BUILD_DATE)
LICENSE_PUBLIC_KEY ?= $(shell cat ../license-public.key 2>/dev/null)
MIABI_LDFLAGS := $(LDFLAGS) -X $(PKG)/internal/enterprise.embeddedPublicKey=$(LICENSE_PUBLIC_KEY)
WEB_DIR := web
EMBED_WEB_DIR := internal/web/dist
SCHEMA_FILE ?= miabi.io-v1.schema.json
INSTALL_SCHEMA_FILE ?= install.miabi.io-v1.schema.json
.PHONY: run worker build build-ui build-all dev-ui test lint tidy migrate schema docker docker-rootless compose-up compose-down mwdocs
run: ## Run the API server
go run -tags enterprise -ldflags "$(MIABI_LDFLAGS)" ./cmd/miabi server
worker: ## Run the background worker
go run -tags enterprise -ldflags "$(MIABI_LDFLAGS)" ./cmd/miabi worker
build: ## Build the control-plane binary
go build -tags enterprise -ldflags "$(MIABI_LDFLAGS)" -o bin/$(BINARY) ./cmd/miabi
build-ui: ## Build the web UI (Vue) and stage it for embedding (internal/web/dist)
npm --prefix $(WEB_DIR) ci
npm --prefix $(WEB_DIR) run build
# Stage the build output where `go build` embeds it (internal/web), keeping the
# committed .gitkeep so `go build` still works on a clean tree.
rm -rf $(EMBED_WEB_DIR)
cp -r $(WEB_DIR)/dist $(EMBED_WEB_DIR)
touch $(EMBED_WEB_DIR)/.gitkeep
build-all: build-ui build ## Build the UI and the server binary (the node agent ships from github.com/miabi-io/agent)
dev-ui: ## Run the Vite dev server (proxies /api/v1 -> :9000)
npm --prefix $(WEB_DIR) run dev
test: ## Run tests (enterprise build tag — matches the shipped binary)
go test -tags enterprise ./...
lint: ## Static analysis
go vet ./...
@command -v golangci-lint >/dev/null 2>&1 && golangci-lint run || echo "golangci-lint not installed, skipping"
schema: ## Generate the JSON Schemas
go run ./cmd/schemagen -o schema/$(SCHEMA_FILE) -install-o schema/$(INSTALL_SCHEMA_FILE)
@for d in ../docs/static/schema ../vscode-miabi/schemas; do \
if [ -d "$$(dirname $$d)" ]; then mkdir -p "$$d" && \
cp schema/$(SCHEMA_FILE) "$$d/" && echo " -> $$d/$(SCHEMA_FILE)" && \
cp schema/$(INSTALL_SCHEMA_FILE) "$$d/" && echo " -> $$d/$(INSTALL_SCHEMA_FILE)"; fi; \
done
mwdocs: ## Generate the middleware reference pages for the docs site
@if [ -d ../docs/docs ]; then \
go run ./cmd/mwdocsgen -o ../docs/docs/middlewares; \
else \
echo "docs site not checked out beside this repository; skipping"; \
fi
tidy: ## Sync go.mod / go.sum
go mod tidy
docker: ## Build the Docker image
docker build --build-arg VERSION=$(VERSION) --build-arg COMMIT=$(COMMIT) \
--build-arg GO_TAGS=enterprise --build-arg LICENSE_PUBLIC_KEY=$(LICENSE_PUBLIC_KEY) \
-f docker/Dockerfile -t miabi:$(VERSION) .
docker-rootless: ## Build the Docker image
docker build --build-arg VERSION=$(VERSION) --build-arg COMMIT=$(COMMIT) \
--build-arg GO_TAGS=enterprise --build-arg LICENSE_PUBLIC_KEY=$(LICENSE_PUBLIC_KEY) \
-f docker/Dockerfile.rootless -t miabi:$(VERSION)-rootless .
compose-up: ## Start local dev stack (builds app + Postgres + Redis)
docker compose -f compose.dev.yaml up -d
compose-down: ## Stop local dev stack
docker compose -f compose.dev.yaml down