forked from k8s-community/ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
77 lines (59 loc) · 2.09 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
70
71
72
73
74
75
76
77
all: push
BUILDTAGS=
# Use the 0.0.0 tag for testing, it shouldn't clobber any release builds
APP?=k8s-community
CHARTS?=charts
USERSPACE?=k8s-community
RELEASE?=0.1.5
PROJECT?=github.com/${USERSPACE}/${APP}
HELM_REPO?=https://services.k8s.community/charts
GOOS?=linux
REGISTRY?=registry.k8s.community
SERVICE_PORT?=8080
NAMESPACE?=default
PREFIX?=${REGISTRY}/${NAMESPACE}/${APP}
CONTAINER_NAME?=${APP}-${NAMESPACE}
ifeq ($(NAMESPACE), default)
PREFIX=${REGISTRY}/${APP}
CONTAINER_NAME=${APP}
endif
REPO_INFO=$(shell git config --get remote.origin.url)
ifndef COMMIT
COMMIT := git-$(shell git rev-parse --short HEAD)
endif
vendor: clean
go get -u github.com/Masterminds/glide \
&& glide install
build: vendor
CGO_ENABLED=0 GOOS=${GOOS} go build -a -installsuffix cgo \
-ldflags "-s -w -X ${PROJECT}/version.RELEASE=${RELEASE} -X ${PROJECT}/version.COMMIT=${COMMIT} -X ${PROJECT}/version.REPO=${REPO_INFO}" \
-o ${APP}
container: build
docker build --pull -t $(PREFIX):$(RELEASE) .
push: container
docker push $(PREFIX):$(RELEASE)
run: container
docker run --name ${CONTAINER_NAME} -p ${SERVICE_PORT}:${SERVICE_PORT} \
-e "SERVICE_PORT=${SERVICE_PORT}" \
-d $(PREFIX):$(RELEASE)
deploy: push
helm repo add ${USERSPACE} ${HELM_REPO} \
&& helm repo up \
&& helm upgrade ${CONTAINER_NAME} ${USERSPACE}/${APP} --namespace ${NAMESPACE} --set image.tag=${RELEASE} -i --wait
fmt:
@echo "+ $@"
@go list -f '{{if len .TestGoFiles}}"gofmt -s -l {{.Dir}}"{{end}}' $(shell go list ${PROJECT}/... | grep -v vendor) | xargs -L 1 sh -c
lint:
@echo "+ $@"
@go list -f '{{if len .TestGoFiles}}"golint {{.Dir}}/..."{{end}}' $(shell go list ${PROJECT}/... | grep -v vendor) | xargs -L 1 sh -c
vet:
@echo "+ $@"
@go vet $(shell go list ${PROJECT}/... | grep -v vendor)
test: vendor fmt lint vet
@echo "+ $@"
@go test -v -race -tags "$(BUILDTAGS) cgo" $(shell go list ${PROJECT}/... | grep -v vendor)
cover:
@echo "+ $@"
@go list -f '{{if len .TestGoFiles}}"go test -coverprofile={{.Dir}}/.coverprofile {{.ImportPath}}"{{end}}' $(shell go list ${PROJECT}/... | grep -v vendor) | xargs -L 1 sh -c
clean:
rm -f ${APP}