forked from ovh/noderig
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
69 lines (52 loc) · 2.15 KB
/
Makefile
File metadata and controls
69 lines (52 loc) · 2.15 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
BUILD_DIR=build
CC=go build
GITHASH=$(shell git rev-parse HEAD)
DFLAGS=-race
CFLAGS=-X github.com/ovh/noderig/cmd.githash=$(GITHASH)
CROSS=GOOS=linux GOARCH=amd64
rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))
VPATH= $(BUILD_DIR)
.SECONDEXPANSION:
build: noderig.go $$(call rwildcard, ./cmd, *.go) $$(call rwildcard, ./collectors, *.go)
$(CC) $(DFLAGS) -ldflags "$(CFLAGS)" -o $(BUILD_DIR)/noderig noderig.go
.PHONY: release
release: noderig.go $$(call rwildcard, ./cmd, *.go) $$(call rwildcard, ./collectors, *.go)
$(CC) -ldflags "$(CFLAGS)" -o $(BUILD_DIR)/noderig noderig.go
.PHONY: dist
dist: noderig.go $$(call rwildcard, ./cmd, *.go) $$(call rwildcard, ./collectors, *.go)
$(CROSS) $(CC) -ldflags "$(CFLAGS) -s -w" -o $(BUILD_DIR)/noderig noderig.go
.PHONY: lint
lint:
@command -v gometalinter >/dev/null 2>&1 || { echo >&2 "gometalinter is required but not available please follow instructions from https://github.com/alecthomas/gometalinter"; exit 1; }
gometalinter --deadline=180s --disable-all --enable=gofmt ./cmd/... ./core/... ./
gometalinter --deadline=180s --disable-all --enable=vet ./cmd/... ./core/... ./
gometalinter --deadline=180s --disable-all --enable=golint ./cmd/... ./core/... ./
gometalinter --deadline=180s --disable-all --enable=ineffassign ./cmd/... ./core/... ./
gometalinter --deadline=180s --disable-all --enable=misspell ./cmd/... ./core/... ./
gometalinter --deadline=180s --disable-all --enable=staticcheck ./cmd/... ./core/... ./
.PHONY: format
format:
gofmt -w -s ./cmd ./core noderig.go
.PHONY: dev
dev: format lint build
.PHONY: clean
clean:
rm -rf $BUILD_DIR
# Docker build
build-docker: build-go-in-docker build-docker-image
glide-install:
go get github.com/Masterminds/glide
glide install
go-build-in-docker:
$(CC) -ldflags "$(CFLAGS)" noderig.go
build-go-in-docker:
docker run --rm \
-e GOBIN=/go/bin/ -e CGO_ENABLED=0 -e GOPATH=/go \
-v ${PWD}:/go/src/github.com/ovh/noderig \
-w /go/src/github.com/ovh/noderig \
golang:1.8.0 \
make glide-install go-build-in-docker
build-docker-image:
docker build -t ovh/noderig .
run:
docker run --rm --net host ovh/noderig