-
Notifications
You must be signed in to change notification settings - Fork 240
/
Makefile
144 lines (122 loc) · 4.92 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# Copyright 2018 Naftis Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
SHELL := /bin/bash
BASE_PATH := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
TITLE := $(shell basename $(BASE_PATH))
SHORT_REV := $(shell git rev-parse HEAD | cut -c1-8)
BUILD_TIME := $(shell date +%Y-%m-%d--%T)
APP_PKG := $(shell $(BASE_PATH)/tool/apppkg.sh)
UI := $(BASE_PATH)/src/ui
TAG := $(shell $(BASE_PATH)/tool/tag.sh) # TODO
export BIN_OUT := $(BASE_PATH)/bin
all: print fmt lint vet test build docker push
print:
@echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>making print<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
@echo SHELL:$(SHELL)
@echo BASE_PATH:$(BASE_PATH)
@echo TITLE:$(TITLE)
@echo SHORT_REV:$(SHORT_REV)
@echo APP_PKG:$(APP_PKG)
@echo BIN_OUT:$(BIN_OUT)
@echo USER:$(USER)
@echo HUB:$(HUB)
@echo UI:$(UI)
@echo TAG:$(TAG)
@echo -e "\n"
fmt:
@echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>making fmt<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
go fmt $(APP_PKG)/src/api/...
@echo -e "\n"
lint:
@echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>making lint<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
@LINTOUT=`$(GOPATH)/bin/golint $(BASE_PATH)/src/api/... | grep -v pb.go`;\
if [ "$$LINTOUT" != "" ]; then\
/bin/echo -E $$LINTOUT;\
exit 1;\
else\
echo "lint success";\
fi
@echo -e "\n"
vet:
@echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>making vet<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
@VETOUT=`go vet $(APP_PKG)/src/api/... 2>&1`;\
if [ "$$VETOUT" != "" ]; then\
echo $$VETOUT;\
exit 1;\
else\
echo "vet success";\
fi
@echo -e "\n"
test:
@echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>making test<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
@echo "test success" # TODO add test script
@echo -e "\n"
build: print build.api build.ui build.manifest
build.api:
@echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>making build.api<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
tool/build.sh ${BIN_OUT}/naftis-api ${APP_PKG}/src/api/version ${APP_PKG}/src/api
@echo -e "\n"
build.manifest:
@echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>making build.manifest<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
tool/genmanifest.sh config/in-cluster.toml
@echo -e "\n"
build.ui:
@echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>making build.ui<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
@cd $(UI) && npm i && npm run build && cp -r dist $(BASE_PATH)/
@echo -e "\n"
docker: docker.api docker.ui
docker.api:
@echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>making docker.api<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
@docker build -t $(HUB)/naftis-api:$(TAG) -f ./Dockerfile.api .
@docker tag $(HUB)/naftis-api:$(TAG) $(HUB)/naftis-api:latest
@echo -e "\n"
docker.apidebug:
@echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>making docker.apidebug<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
@docker build -t $(HUB)/naftis-api:debug -f ./Dockerfile.api_debug .
@echo -e "\n"
docker.ui:
@echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>making docker.ui<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
@docker build -t $(HUB)/naftis-ui:$(TAG) -f ./Dockerfile.ui .
@docker tag $(HUB)/naftis-ui:$(TAG) $(HUB)/naftis-ui:latest
@echo -e "\n"
docker.login:
@echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>making docker.login<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
echo "$(DOCKER_PASSWORD)" | docker login -u "$(DOCKER_USERNAME)" --password-stdin
@echo -e "\n"
push:
@echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>making push<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
@make push.api push.ui
@echo -e "\n"
push.api:
@echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>making push.api<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
@docker push $(HUB)/naftis-api:$(TAG)
@docker push $(HUB)/naftis-api:latest
@echo -e "\n"
push.ui:
@echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>making push.ui<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
@docker push $(HUB)/naftis-ui:$(TAG)
@docker push $(HUB)/naftis-ui:latest
@echo -e "\n"
release:
@echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>making push.ui<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
@make build.manifest
@rm -rf $(BASE_PATH)/vendor $(BASE_PATH)/src $(BASE_PATH)/dist
@rm .gitattributes .gitignore .travis.yml Dockerfile.* Gopkg.* Makefile run
@echo -e "\n"
tar:
@echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>making tar<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
$(eval TAR=$(BASE_PATH)/$(TITLE)_$(SHORT_REV).tar.gz)
@cd $(BASE_PATH) && tar zcf $(TAR) bin config Gopkg.* dist >/dev/null
@echo $(TAR)
@echo -e "\n"