forked from openpitrix/openpitrix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
132 lines (107 loc) · 3.2 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
# Copyright 2017 The OpenPitrix Authors. All rights reserved.
# Use of this source code is governed by a Apache license
# that can be found in the LICENSE file.
TARG.Name:=openpitrix
TRAG.Gopkg:=openpitrix.io/openpitrix
DOCKER_TAGS=latest
MAKE_IN_DOCKER:=docker run --rm -it -v `pwd`:/go/src/$(TRAG.Gopkg) -w /go/src/$(TRAG.Gopkg) openpitrix/openpitrix-builder make
MYSQL_DATABASE:=$(TARG.Name)
MYSQL_ROOT_PASSWORD:=password
.PHONY: all
all: build-in-docker test release
.PHONY: help
help:
@echo "Please use \`make <target>\` where <target> is one of"
@echo " all to generate, test and release"
@echo " start to start services (port:9100)"
@echo " stop to stop services"
@echo " tools to install depends tools"
@echo " init-vendor to init vendor packages"
@echo " update-vendor to update vendor packages"
@echo " generate to generate restapi code"
@echo " build to build the services"
@echo " build-in-docker to build the services using docker without installing any dependence"
@echo " test to run go test ./..."
@echo " release to build and release current version"
@echo " clean to clean the temp files"
.PHONY: init-vendor
init-vendor:
@if [[ ! -f "$$(which govendor)" ]]; then \
go get -u github.com/kardianos/govendor; \
fi
govendor init
govendor add +external
@echo "ok"
.PHONY: update-vendor
update-vendor:
@if [[ ! -f "$$(which govendor)" ]]; then \
go get -u github.com/kardianos/govendor; \
fi
govendor update +external
govendor list
@echo "ok"
.PHONY: tools
tools:
docker pull openpitrix/openpitrix:builder
docker pull mysql:5.6
@echo "ok"
.PHONY: generate
generate:
cd ./api && make generate
cd ./pkg/cmd/api && make
go generate ./pkg/version/
.PHONY: mysql-start
mysql-start:
@docker run --rm --name openpitrix-db -e MYSQL_ROOT_PASSWORD=$(MYSQL_ROOT_PASSWORD) -e MYSQL_DATABASE=$(MYSQL_DATABASE) -p 3306:3306 -d mysql:5.6 || docker start openpitrix-db
@echo "ok"
.PHONY: mysql-stop
mysql-stop:
@docker stop openpitrix-db
@echo "ok"
.PHONY: build
build:
make generate
docker build -t $(TARG.Name) -f ./Dockerfile .
@docker image prune -f 1>/dev/null 2>&1
@echo "ok"
.PHONY: build-in-docker
build-in-docker:
$(MAKE_IN_DOCKER) generate
docker build -t $(TARG.Name) -f ./Dockerfile .
@docker image prune -f 1>/dev/null 2>&1
@echo "ok"
.PHONY: start
start:
docker-compose up -d
@echo "ok"
.PHONY: stop
stop:
docker-compose down
@echo "ok"
.PHONY: release
release:
@echo "TODO"
.PHONY: test
test:
docker-compose up --build -d
sleep 10
curl localhost:9100/ping
curl localhost:9100/panic
curl localhost:9100/v1/apps
curl localhost:9100/v1/appruntimes
curl localhost:9100/v1/clusters
curl localhost:9100/v1/repos
curl localhost:9100/v1/apps/invalid-id
curl localhost:9100/v1/appruntimes/invalid-id
curl localhost:9100/v1/clusters/invalid-id
curl localhost:9100/v1/repos/invalid-id
curl localhost:9100/v1/apps/app-panic000
curl localhost:9100/v1/appruntimes/rt-panic000
curl localhost:9100/v1/clusters/cl-panic000
curl localhost:9100/v1/repos/repo-panic000
docker-compose down
@echo "ok"
.PHONY: clean
clean:
-make -C ./pkg/version clean
@echo "ok"