-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
102 lines (79 loc) · 2.73 KB
/
Copy pathMakefile
File metadata and controls
102 lines (79 loc) · 2.73 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
.PHONY: build build-all test lint fmt fmt-check vet clean install docker docker-release docker-buildx-setup docker-login docker-push docker-publish version tag-version release ci
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
LDFLAGS := -ldflags="-s -w -X main.version=$(VERSION)"
# Docker Hub configuration
DOCKER_REPO ?= portertech/filesystem-mcp-server
DOCKER_PLATFORMS ?= linux/amd64,linux/arm64
DOCKER_BUILDER ?= filesystem-builder
# Build the binary
build:
go build $(LDFLAGS) -o filesystem ./cmd/filesystem
# Build everything (binary + docker)
build-all: build docker
# Run all tests
test:
go test ./...
# Run tests with verbose output
test-v:
go test -v ./...
# Run tests with coverage
test-cover:
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
# Format code
fmt:
gofmt -w .
# Check formatting (fails if not formatted)
fmt-check:
@test -z "$$(gofmt -l .)" || (echo "Files not formatted:"; gofmt -l .; exit 1)
# Run go vet
vet:
go vet ./...
# All linting checks
lint: fmt-check vet
# Clean build artifacts
clean:
rm -f filesystem coverage.out coverage.html
go clean -testcache
# Install to GOPATH/bin
install:
go install $(LDFLAGS) ./cmd/filesystem
# Build Docker image
docker:
docker build -t filesystem-mcp-server:latest .
# Build Docker image with version tag
docker-release:
docker build -t filesystem-mcp-server:$(VERSION) -t filesystem-mcp-server:latest .
# Setup buildx builder for multi-arch builds
docker-buildx-setup:
@docker buildx inspect $(DOCKER_BUILDER) >/dev/null 2>&1 || \
docker buildx create --name $(DOCKER_BUILDER) --driver docker-container --bootstrap
@docker buildx use $(DOCKER_BUILDER)
# Login to Docker Hub (requires DOCKER_USERNAME and DOCKER_PASSWORD env vars)
docker-login:
@echo "$(DOCKER_PASSWORD)" | docker login -u "$(DOCKER_USERNAME)" --password-stdin
# Build and push multi-arch image to Docker Hub
docker-push: docker-buildx-setup
docker buildx build \
--platform $(DOCKER_PLATFORMS) \
--tag $(DOCKER_REPO):$(VERSION) \
--tag $(DOCKER_REPO):latest \
--push .
# Publish to Docker Hub (assumes already logged in, or use docker-login first)
docker-publish: docker-push
# Run all checks (used in CI)
ci: lint test
# List version
version:
@echo $(VERSION)
# Create annotated git tag (requires VERSION to be set explicitly)
tag-version:
@if [ "$(VERSION)" = "dev" ] || echo "$(VERSION)" | grep -q dirty; then \
echo "Error: VERSION must be set explicitly and not be 'dev' or dirty"; \
echo "Usage: make tag-version VERSION=1.0.0"; \
exit 1; \
fi
git tag -a "v$(VERSION)" -m "v$(VERSION)"
# Full release: ci -> tag-version -> docker-publish
# Usage: make release VERSION=1.0.0
release: ci tag-version docker-publish