-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
120 lines (98 loc) · 3.53 KB
/
Copy pathMakefile
File metadata and controls
120 lines (98 loc) · 3.53 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
include ./make/*.mk
.PHONY: build build-server build-agent run test vet clean fmt lint deps build-prod help image-agent image-server
# Application name
APP_NAME = cli-mcp-server
# Build variables
BUILD_DIR = bin
# Go package path for ldflags
GO_PACKAGE_ORG_NAME ?= codeready-toolchain
GO_PACKAGE_REPO_NAME ?= $(shell basename $$PWD)
GO_PACKAGE_PATH ?= github.com/${GO_PACKAGE_ORG_NAME}/${GO_PACKAGE_REPO_NAME}
LDFLAGS = -X ${GO_PACKAGE_PATH}/pkg/version.commitOverride=${GIT_COMMIT_ID} -X ${GO_PACKAGE_PATH}/pkg/version.BuildTime=${BUILD_TIME}
# Go parameters
GOCMD = go
GOBUILD = $(GOCMD) build
GOCLEAN = $(GOCMD) clean
GOTEST = $(GOCMD) test
GOMOD = $(GOCMD) mod
GOFMT = gofmt
# Build both binaries
build: build-server build-agent
# Build the MCP server (control plane)
build-server:
@echo "Building server (commit: $(GIT_COMMIT_ID_SHORT))..."
@mkdir -p $(BUILD_DIR)
$(GOBUILD) -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/server -v ./cmd/server
# Build the sandbox agent (data plane)
build-agent:
@echo "Building agent (commit: $(GIT_COMMIT_ID_SHORT))..."
@mkdir -p $(BUILD_DIR)
$(GOBUILD) -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/agent -v ./cmd/agent
# Run the server
run:
$(GOCMD) run ./cmd/server
# Test the application
test:
$(GOTEST) -v ./...
# Vet the application
vet:
$(GOCMD) vet ./...
# Test with coverage
test-coverage:
$(GOTEST) -v -coverprofile=coverage.out ./...
$(GOCMD) tool cover -html=coverage.out -o coverage.html
# Clean build artifacts
clean:
$(GOCLEAN)
rm -rf $(BUILD_DIR)
rm -f coverage.out
# Format code
fmt:
$(GOFMT) -s -w .
# Lint code (requires golangci-lint)
lint:
golangci-lint run
# Download dependencies
deps:
$(GOMOD) download
$(GOMOD) tidy
# Build for production (both binaries, static, CGO disabled)
build-prod: build-prod-server build-prod-agent
build-prod-server:
@echo "Building server for production (commit: $(GIT_COMMIT_ID_SHORT))..."
@mkdir -p $(BUILD_DIR)
CGO_ENABLED=0 GOOS=linux $(GOBUILD) -a -installsuffix cgo -ldflags '$(LDFLAGS) -extldflags "-static"' -o $(BUILD_DIR)/server ./cmd/server
build-prod-agent:
@echo "Building agent for production (commit: $(GIT_COMMIT_ID_SHORT))..."
@mkdir -p $(BUILD_DIR)
CGO_ENABLED=0 GOOS=linux $(GOBUILD) -a -installsuffix cgo -ldflags '$(LDFLAGS) -extldflags "-static"' -o $(BUILD_DIR)/agent ./cmd/agent
image-agent:
podman build -f Containerfile.agent \
--build-arg GIT_COMMIT=$(GIT_COMMIT_ID) \
--build-arg BUILD_TIME=$(BUILD_TIME) \
-t cli-mcp-sandbox:latest .
image-server:
podman build -f Containerfile.server \
--build-arg GIT_COMMIT=$(GIT_COMMIT_ID) \
--build-arg BUILD_TIME=$(BUILD_TIME) \
-t cli-mcp-server:latest .
# Help
help:
@echo "Available targets:"
@echo " build - Build both server and agent binaries"
@echo " build-server - Build the MCP server binary"
@echo " build-agent - Build the sandbox agent binary"
@echo " run - Run the MCP server"
@echo " test - Run tests"
@echo " vet - Run go vet"
@echo " test-coverage - Run tests with coverage"
@echo " clean - Clean build artifacts"
@echo " fmt - Format code"
@echo " lint - Lint code"
@echo " deps - Download dependencies"
@echo " build-prod - Build both binaries for production"
@echo " build-prod-server- Build server for production"
@echo " build-prod-agent - Build agent for production"
@echo " image-agent - Build sandbox agent container image"
@echo " image-server - Build MCP server container image"
@echo " help - Show this help"