-
Notifications
You must be signed in to change notification settings - Fork 98
/
Copy pathMakefile
166 lines (144 loc) · 4.56 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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.
#
version=0
checkout=0
app=0
type=0
image_base="centos"
image_tag="7"
iteration=0
local_code_path=0
openresty="openresty"
artifact="0"
apisix_repo="https://github.com/apache/apisix"
dashboard_repo="https://github.com/apache/apisix-dashboard"
### set the default image for deb package
ifeq ($(type), deb)
image_base="ubuntu"
image_tag="20.04"
endif
### function for building
### $(1) is name
### $(2) is dockerfile filename
### $(3) is package type
### $(4) is code path
define build
docker build -t apache/$(1)-$(3):$(version) \
--build-arg checkout_v=$(checkout) \
--build-arg IMAGE_BASE=$(image_base) \
--build-arg IMAGE_TAG=$(image_tag) \
--build-arg CODE_PATH=$(4) \
-f ./dockerfiles/Dockerfile.$(2).$(3) .
endef
### function for packing
### $(1) is name
### $(2) is package type
define package
docker build -t apache/$(1)-packaged-$(2):$(version) \
--build-arg VERSION=$(version) \
--build-arg ITERATION=$(iteration) \
--build-arg PACKAGE_VERSION=$(version) \
--build-arg PACKAGE_TYPE=$(2) \
--build-arg OPENRESTY=$(openresty) \
--build-arg ARTIFACT=$(artifact) \
-f ./dockerfiles/Dockerfile.package.$(1) .
docker run -d --rm --name output --net="host" apache/$(1)-packaged-$(2):$(version)
docker cp output:/output ${PWD}
docker stop output
docker system prune -a -f
endef
### build apisix:
.PHONY: build-apisix-rpm
build-apisix-rpm:
ifeq ($(local_code_path), 0)
git clone -b $(checkout) $(apisix_repo) ./apisix
$(call build,apisix,apisix,rpm,"./apisix")
rm -fr ./apisix
else
$(call build,apisix,apisix,rpm,$(local_code_path))
endif
.PHONY: build-apisix-deb
build-apisix-deb:
ifeq ($(local_code_path), 0)
git clone -b $(checkout) $(apisix_repo) ./apisix
$(call build,apisix,apisix,deb,"./apisix")
rm -fr ./apisix
else
$(call build,apisix,apisix,deb,$(local_code_path))
endif
### build rpm for apisix:
.PHONY: package-apisix-rpm
package-apisix-rpm:
$(call package,apisix,rpm)
.PHONY: package-apisix-deb
package-apisix-deb:
$(call package,apisix,deb)
### build dashboard:
.PHONY: build-dashboard-rpm
build-dashboard-rpm:
ifeq ($(local_code_path), 0)
git clone -b $(checkout) $(dashboard_repo) ./apisix-dashboard
$(call build,apisix-dashboard,dashboard,rpm,"./apisix-dashboard")
rm -fr ./apisix-dashboard
else
$(call build,apisix-dashboard,dashboard,rpm,$(local_code_path))
endif
### build rpm for apisix dashboard:
.PHONY: package-dashboard-rpm
package-dashboard-rpm:
$(call package,apisix-dashboard,rpm)
### build apisix-openresty:
.PHONY: build-apisix-openresty-rpm
build-apisix-openresty-rpm:
docker build -t apache/apisix-openresty-rpm:$(version) \
--build-arg version=$(version) \
--build-arg IMAGE_BASE=$(image_base) \
--build-arg IMAGE_TAG=$(image_tag) \
-f ./dockerfiles/Dockerfile.apisix-openresty.rpm .
### build rpm for apisix-openresty:
.PHONY: package-apisix-openresty-rpm
package-apisix-openresty-rpm:
$(call package,apisix-openresty,rpm)
### build fpm for packaging:
.PHONY: build-fpm
build-fpm:
docker build -t api7/fpm - < ./dockerfiles/Dockerfile.fpm
ifeq ($(filter $(app),apisix dashboard apisix-openresty),)
$(info the app's value have to be apisix or dashboard!)
else ifeq ($(filter $(type),rpm deb),)
$(info the type's value have to be rpm or deb!)
else ifeq ($(version), 0)
$(info you have to input a version value!)
else ifeq ($(app)_$(type),apisix-openresty_rpm)
package: build-fpm
package: build-apisix-openresty-rpm
package: package-apisix-openresty-rpm
else ifeq ($(checkout), 0)
$(info you have to input a checkout value!)
else ifeq ($(app)_$(type),apisix_rpm)
package: build-fpm
package: build-apisix-rpm
package: package-apisix-rpm
else ifeq ($(app)_$(type),apisix_deb)
package: build-fpm
package: build-apisix-deb
package: package-apisix-deb
else ifeq ($(app)_$(type),dashboard_rpm)
package: build-fpm
package: build-dashboard-rpm
package: package-dashboard-rpm
endif