forked from solo-io/gloo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
265 lines (201 loc) · 7.85 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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
# Change this if your googleapis is in a different directory
ifndef GOOGLE_PROTOS_HOME
export GOOGLE_PROTOS_HOME=$(HOME)/workspace/googleapis
endif
ROOTDIR := $(shell pwd)
PROTOS := $(shell find api/v1 -name "*.proto")
SOURCES := $(shell find . -name "*.go" | grep -v test)
GENERATED_PROTO_FILES := $(shell find pkg/api/types/v1 -name "*.pb.go")
OUTPUT_DIR ?= $(ROOTDIR)/_output
PACKAGE_PATH:=github.com/solo-io/gloo
#----------------------------------------------------------------------------------
# Build
#----------------------------------------------------------------------------------
# Generated code
.PHONY: all
all: build
.PHONY: proto
proto: $(GENERATED_PROTO_FILES)
$(GENERATED_PROTO_FILES): $(PROTOS)
cd api/v1/ && \
mkdir -p $(ROOTDIR)/pkg/api/types/v1 && \
protoc \
--gogo_out=Mgoogle/protobuf/struct.proto=github.com/gogo/protobuf/types,Mgoogle/protobuf/duration.proto=github.com/gogo/protobuf/types:$(GOPATH)/src/ \
-I=$(GOPATH)/src/github.com/gogo/protobuf/ \
-I=$(GOPATH)/src/github.com/gogo/protobuf/protobuf/ \
-I=. \
./*.proto
$(OUTPUT_DIR):
mkdir -p $@
# kubernetes custom clientsets
.PHONY: clientset
clientset: $(OUTPUT_DIR)/.clientset
$(OUTPUT_DIR)/.clientset: $(GENERATED_PROTO_FILES) $(SOURCES)
cd ${GOPATH}/src/k8s.io/code-generator && \
./generate-groups.sh all \
$(PACKAGE_PATH)/pkg/storage/crd/client \
$(PACKAGE_PATH)/pkg/storage/crd \
"solo.io:v1"
touch $@
.PHONY: generated-code
generated-code: $(OUTPUT_DIR)/.generated-code
$(OUTPUT_DIR)/.generated-code:
go generate ./pkg/...
touch $@
# Core Binaries
BINARIES ?= control-plane function-discovery kube-ingress-controller upstream-discovery
DEBUG_BINARIES = $(foreach BINARY,$(BINARIES),$(BINARY)-debug)
DOCKER_ORG=soloio
.PHONY: build
build: $(BINARIES)
.PHONY: debug-build
debug-build: $(DEBUG_BINARIES)
docker: $(foreach BINARY,$(BINARIES),$(shell echo $(BINARY)-docker))
docker-push: $(foreach BINARY,$(BINARIES),$(shell echo $(BINARY)-docker-push))
define BINARY_TARGETS
$(eval VERSION := $(shell cat version))
$(eval IMAGE_TAG ?= $(VERSION))
$(eval OUTPUT_BINARY := $(OUTPUT_DIR)/$(BINARY))
.PHONY: $(BINARY)
.PHONY: $(BINARY)-debug
.PHONY: $(BINARY)-docker
.PHONY: $(BINARY)-docker-debug
.PHONY: $(BINARY)-docker-push
.PHONY: $(BINARY)-docker-push-debug
# nice targets for the binaries
$(BINARY): $(OUTPUT_BINARY)
$(BINARY)-debug: $(OUTPUT_BINARY)-debug
# go build
$(OUTPUT_BINARY): $(OUTPUT_DIR) $(PREREQUISITES)
CGO_ENABLED=0 GOOS=linux go build -v -o $(OUTPUT_BINARY) cmd/$(BINARY)/main.go
$(OUTPUT_BINARY)-debug: $(OUTPUT_DIR) $(PREREQUISITES)
go build -i -gcflags "all=-N -l" -o $(OUTPUT_BINARY)-debug cmd/$(BINARY)/main.go
# docker
$(BINARY)-docker: $(OUTPUT_BINARY)
docker build -t $(DOCKER_ORG)/$(BINARY):$(IMAGE_TAG) $(OUTPUT_DIR) -f - < cmd/$(BINARY)/Dockerfile
$(BINARY)-docker-debug: $(OUTPUT_BINARY)-debug
docker build -t $(DOCKER_ORG)/$(BINARY)-debug:$(IMAGE_TAG) $(OUTPUT_DIR) -f - < cmd/$(BINARY)/Dockerfile.debug
$(BINARY)-docker-push: $(BINARY)-docker
docker push $(DOCKER_ORG)/$(BINARY):$(IMAGE_TAG)
$(BINARY)-docker-push-debug: $(BINARY)-docker-debug
docker push $(DOCKER_ORG)/$(BINARY)-debug:$(IMAGE_TAG)
endef
PREREQUISITES := $(SOURCES) $(GENERATED_PROTO_FILES) generated-code clientset
$(foreach BINARY,$(BINARIES),$(eval $(BINARY_TARGETS)))
# localgloo
.PHONY: localgloo
localgloo: $(OUTPUT_DIR)/localgloo
$(OUTPUT_DIR)/localgloo: $(OUTPUT_DIR) $(PREREQUISITES)
go build -i -gcflags "all=-N -l" -o $@ cmd/localgloo/main.go
# clean
clean:
rm -rf $(OUTPUT_DIR)
#----------------------------------------------------------------------------------
# Installation Manifests
#----------------------------------------------------------------------------------
.PHONY: manifests
manifests: install/kube/install.yaml install/openshift/install.yaml
install/kube/install.yaml: $(shell find install/helm/ -name '*.yaml')
cat install/helm/bootstrap.yaml \
| sed -e "s/{{ .Namespace }}/gloo-system/" > $@
echo >> $@
echo >> $@
helm template --namespace gloo-system \
-f install/helm/gloo/values.yaml \
-n REMOVEME install/helm/gloo | \
sed s/REMOVEME-//g | \
sed '/^.*REMOVEME$$/d' >> $@
install/openshift/install.yaml: install/kube/install.yaml
cat install/kube/install.yaml \
| sed -e "s@apps/v1beta2@extensions/v1beta1@" \
| sed -e "s@rbac.authorization.k8s.io/v1@rbac.authorization.k8s.io/v1beta1@" > $@
#----------------------------------------------------------------------------------
# Docs
#----------------------------------------------------------------------------------
PLUGIN_PROTOS=$(shell find pkg/coreplugins/ -maxdepth 2 -name *.proto && find pkg/plugins/ -maxdepth 2 -name *.proto)
PROTO_FILES=$(foreach PROTO,$(PLUGIN_PROTOS),$(ROOTDIR)/$(PROTO)) ./*.proto
docs/api.json: $(PROTOS)
export DISABLE_SORT=1 && \
cd api/v1/ && \
mkdir -p $(ROOTDIR)/pkg/api/types/v1 && \
protoc \
-I=. \
-I=$(GOPATH)/src \
-I=$(GOPATH)/src/github.com/gogo/protobuf/ \
-I=${GOPATH}/src/github.com/lyft/protoc-gen-validate/ \
--plugin=protoc-gen-doc=$(GOPATH)/bin/protoc-gen-doc \
--doc_out=$(ROOTDIR)/docs/ \
--doc_opt=json,api.json \
$(PROTO_FILES)
.PHONY: doc
doc: docs/api.json
go run docs/gen_docs.go
site: doc
mkdocs build
docker-docs: site
docker build -t $(DOCKER_ORG)/nginx-docs:$(VERSION) -f Dockerfile.site .
#----------------------------------------------------------------------------------
# Test
#----------------------------------------------------------------------------------
hackrun: $(BINARY)
./hack/run-local.sh
unit:
ginkgo -r pkg/
e2e:
ginkgo -r test/
test: unit e2e
#----------------------------------------------------------------------------------
# Envoy
#----------------------------------------------------------------------------------
.PHONY: envoy
envoy: $(OUTPUT_DIR)/envoy
$(OUTPUT_DIR)/envoy:
cd build-envoy && bazel build -c dbg //:envoy
envoy-in-docker:
docker run -v $(ROOTDIR):$(ROOTDIR) -v $(ROOTDIR)/build-envoy/bazel-docker-cache:/root/.cache/ -w $(ROOTDIR)/build-envoy envoyproxy/envoy-build bash -c "bazel build -c dbg //:envoy && cd .. && cp -f build-envoy/bazel-bin/envoy $(OUTPUT_DIR)"
envoy-dev-docker: envoy
cp -f build-envoy/Dockerfile build-envoy/bazel-bin/envoy $(OUTPUT_DIR)
docker build -t soloio/envoy-dev:$(IMAGE_TAG) $(OUTPUT_DIR)
envoy-release:
./build-envoy/ci/run_envoy_docker.sh "./build-envoy/ci/build.sh"
envoy-docker: envoy-release
cp -f build-envoy/Dockerfile $(OUTPUT_DIR)
docker build -t soloio/envoy:$(IMAGE_TAG) $(OUTPUT_DIR)
#----------------------------------------------------------------------------------
# glooctl
#----------------------------------------------------------------------------------
# glooctl target
# relies on glooctl sources being located in ../glooctl
$(OUTPUT_DIR)/glooctl-linux-amd64: $(OUTPUT_DIR) $(shell find ../glooctl/ -name *.go)
cd ../glooctl/ && GOOS=linux go build -o $@ main.go
$(OUTPUT_DIR)/glooctl-darwin-amd64: $(OUTPUT_DIR) $(shell find ../glooctl/ -name *.go)
cd ../glooctl/ && GOOS=darwin go build -o $@ main.go
#----------------------------------------------------------------------------------
# Release
#----------------------------------------------------------------------------------
RELEASE_BINARIES := \
$(OUTPUT_DIR)/glooctl-linux-amd64 \
$(OUTPUT_DIR)/glooctl-darwin-amd64 \
$(OUTPUT_DIR)/control-plane \
$(OUTPUT_DIR)/function-discovery \
$(OUTPUT_DIR)/upstream-discovery \
$(OUTPUT_DIR)/localgloo \
$(OUTPUT_DIR)/envoy
.PHONY: release-binaries
release-binaries: $(RELEASE_BINARIES)
.PHONY: release
release: release-binaries
hack/create-release.sh github_api_token=$(GITHUB_TOKEN) owner=solo-io repo=gloo tag=v$(VERSION)
@$(foreach BINARY,$(RELEASE_BINARIES),hack/upload-github-release-asset.sh github_api_token=$(GITHUB_TOKEN) owner=solo-io repo=gloo tag=v$(VERSION) filename=$(BINARY);)
# TODO: dependnencies
# binaries:
# make
# protoc
# go
# protoc-gen-doc ilackarms version
# docker
# mkdocs
# libs
# libproto
# go packages#
# github.com/gogo/protobuf