forked from openebs/velero-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
65 lines (48 loc) · 1.43 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
BINS = $(wildcard ark-*)
REPO ?= github.com/mynktl/openebs-ark-plugin
BUILD_IMAGE ?= gcr.io/heptio-images/golang:1.9-alpine3.6
IMAGE ?= openebs/ark-plugin
TAG ?= latest
ARCH ?= amd64
ifndef PKGS
PKGS := $(shell go list ./... 2>&1 | grep -v 'github.com/mynktl/openebs-ark-plugin/vendor')
endif
all: $(addprefix build-, $(BINS))
build-%:
$(MAKE) --no-print-directory BIN=$* build
build: _output/$(BIN)
_output/$(BIN): $(BIN)/*.go
mkdir -p .go/src/$(REPO) .go/pkg .go/std/$(ARCH) _output
docker run \
--rm \
-u $$(id -u):$$(id -g) \
-v $$(pwd)/.go/pkg:/go/pkg \
-v $$(pwd)/.go/src:/go/src \
-v $$(pwd)/.go/std:/go/std \
-v $$(pwd):/go/src/$(REPO) \
-v $$(pwd)/.go/std/$(ARCH):/usr/local/go/pkg/linux_$(ARCH)_static \
-e CGO_ENABLED=0 \
-w /go/src/$(REPO) \
$(BUILD_IMAGE) \
go build -installsuffix "static" -i -v -o _output/$(BIN) ./$(BIN)
lint:
go get -v github.com/golang/lint/golint
for file in $$(find . -name '*.go' | grep -v vendor | grep -v '\.pb\.go' | grep -v '\.pb\.gw\.go'); do \
golint $${file}; \
if [ -n "$$(golint $${file})" ]; then \
exit 1; \
fi; \
done
vet:
go vet $(PKGS)
errcheck:
go get -v github.com/kisielk/errcheck
errcheck -verbose -blank $(PKGS)
check: lint errcheck vet
container: all
cp Dockerfile _output/Dockerfile
docker build -t $(IMAGE):$(TAG) -f _output/Dockerfile _output
deploy:
docker push $(IMAGE):$(TAG)
clean:
rm -rf .go _output