forked from zalando-incubator/kube-metrics-adapter
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Makefile
42 lines (31 loc) · 1.23 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
.PHONY: clean test check build.local build.linux build.osx build.docker build.push
BINARY ?= kube-metrics-adapter
VERSION ?= $(shell git describe --tags --always --dirty)
IMAGE ?= registry-write.opensource.zalan.do/teapot/$(BINARY)
TAG ?= $(VERSION)
SOURCES = $(shell find . -name '*.go')
DOCKERFILE ?= Dockerfile
GOPKGS = $(shell go list ./...)
BUILD_FLAGS ?= -v
LDFLAGS ?= -X main.version=$(VERSION) -w -s
default: build.local
clean:
rm -rf build
test:
go test -v $(GOPKGS)
check:
go mod download
golangci-lint run --timeout=2m ./...
build.local: build/$(BINARY)
build.linux: build/linux/$(BINARY)
build.osx: build/osx/$(BINARY)
build/$(BINARY): go.mod $(SOURCES)
CGO_ENABLED=0 go build -o build/$(BINARY) $(BUILD_FLAGS) -ldflags "$(LDFLAGS)" .
build/linux/$(BINARY): go.mod $(SOURCES)
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build $(BUILD_FLAGS) -o build/linux/$(BINARY) -ldflags "$(LDFLAGS)" .
build/osx/$(BINARY): go.mod $(SOURCES)
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build $(BUILD_FLAGS) -o build/osx/$(BINARY) -ldflags "$(LDFLAGS)" .
build.docker: build.linux
docker build --rm -t "$(IMAGE):$(TAG)" -f $(DOCKERFILE) .
build.push: build.docker
docker push "$(IMAGE):$(TAG)"