-
Notifications
You must be signed in to change notification settings - Fork 25
/
Makefile
69 lines (55 loc) · 1.72 KB
/
Makefile
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
PROJECT="nebula-exporter"
GO ?= go
IMAGE_TAG ?= v3.3.0
DOCKER_REPO=vesoft
export GO111MODULE := on
LDFLAGS = $(if $(DEBUGGER),,-s -w)
GOOS := $(if $(GOOS),$(GOOS),linux)
GOARCH := $(if $(GOARCH),$(GOARCH),amd64)
GOENV := GO15VENDOREXPERIMENT="1" CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH)
GO := $(GOENV) go
GO_BUILD := $(GO) build -trimpath
TARGETDIR := "$(GOOS)/$(GOARCH)"
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif
PLATFORMS = arm64 amd64
BUILDX_PLATFORMS = linux/arm64,linux/amd64
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif
all: check build-exporter helm-chart image-multiarch clean
check: fmt vet lint
build-exporter:
$(GO_BUILD) -ldflags '$(LDFLAGS)' -o bin/$(TARGETDIR)/nebula-stats-exporter main.go
helm-chart:
helm repo index charts --url https://vesoft-inc.github.io/nebula-stats-exporter/charts
helm package charts/nebula-exporter
mv nebula-exporter-*.tgz charts/
image-multiarch:
$(foreach PLATFORM,$(PLATFORMS), echo -n "$(PLATFORM)..."; GOARCH=$(PLATFORM) make build-exporter;)
echo "Building and pushing nebula-exporter image... $(BUILDX_PLATFORMS)"
docker buildx rm exporter || true
docker buildx create --driver-opt network=host --use --name=exporter
docker buildx build \
--no-cache \
--pull \
--push \
--progress plain \
--platform $(BUILDX_PLATFORMS) \
-t "${DOCKER_REPO}/nebula-stats-exporter:${IMAGE_TAG}" .
clean:
rm -rf nebula-stats-exporter
docker rmi -f $(DOCKER_REPO)/nebula-stats-exporter:$(IMAGE_TAG)
fmt:
go fmt .
vet:
go vet ./...
lint:
$(GOBIN)/golangci-lint run
.PHONY: all