-
Notifications
You must be signed in to change notification settings - Fork 11
/
Makefile
155 lines (125 loc) · 6.14 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
################################################################################
# Build
################################################################################
IMAGE_NAME = the-coffee-bar
ECR_URL = public.ecr.aws/sumologic
REPO_URL = $(ECR_URL)/$(IMAGE_NAME)
#-------------------------------------------------------------------------------
.PHONY: build-dotnet-apps
build-dotnet-apps:
REPO_URL=${REPO_URL} $(MAKE) -C ./applications/dotnet-core-the-coffee-bar-app build
.PHONY: push-dotnet-apps
push-dotnet-apps:
REPO_URL=${REPO_URL} $(MAKE) -C ./applications/dotnet-core-the-coffee-bar-app push
#-------------------------------------------------------------------------------
.PHONY: build-clicker
build-clicker:
REPO_URL=${REPO_URL} $(MAKE) -C ./applications/js-the-coffee-bar-ui-clicker build
.PHONY: push-clicker
push-clicker:
REPO_URL=${REPO_URL} $(MAKE) -C ./applications/js-the-coffee-bar-ui-clicker push
#-------------------------------------------------------------------------------
.PHONY: build-python-apps
build-python-apps:
REPO_URL=${REPO_URL} $(MAKE) -C ./applications/python-the-coffee-bar-apps build
.PHONY: push-python-apps
push-python-apps:
REPO_URL=${REPO_URL} $(MAKE) -C ./applications/python-the-coffee-bar-apps push
#-------------------------------------------------------------------------------
.PHONY: build-ruby-apps
build-ruby-apps:
REPO_URL=${REPO_URL} $(MAKE) -C ./applications/ruby-the-coffee-bar-apps build
.PHONY: push-ruby-apps
push-ruby-apps:
REPO_URL=${REPO_URL} $(MAKE) -C ./applications/ruby-the-coffee-bar-apps push
#-------------------------------------------------------------------------------
.PHONY: build-frontend
build-frontend:
REPO_URL=${REPO_URL} $(MAKE) -C ./applications/the-coffee-bar-frontend build
.PHONY: push-frontend
push-frontend:
REPO_URL=${REPO_URL} $(MAKE) -C ./applications/the-coffee-bar-frontend push
#-------------------------------------------------------------------------------
.PHONY: build-all
build-all:
$(MAKE) build-frontend
$(MAKE) build-dotnet-apps
$(MAKE) build-clicker
$(MAKE) build-python-apps
$(MAKE) build-ruby-apps
$(MAKE) build-frontend
#-------------------------------------------------------------------------------
.PHONY: _login
_login:
aws ecr-public get-login-password --region us-east-1 \
| docker login --username AWS --password-stdin $(ECR_URL)
.PHONY: login
login:
$(MAKE) _login \
ECR_URL="$(ECR_URL)"
################################################################################
# RELEASE CHART
################################################################################
CHART_NAME = sumologic-the-coffee-bar
#-------------------------------------------------------------------------------
.PHONY: update-chart-version
update-chart-version:
@echo "Updating chart version..."
@current_version=$$(grep "version:" ./deployments/helm/$(CHART_NAME)/Chart.yaml | awk '{print $$2}') ; \
major_version=$$(echo $$current_version | cut -d. -f1) ; \
minor_version=$$(echo $$current_version | cut -d. -f2) ; \
patch_version=$$(echo $$current_version | cut -d. -f3) ; \
new_minor_version=$$((minor_version + 1)) ; \
new_version="$$major_version.$$new_minor_version.$$patch_version" ; \
sed -i '' -E "s/version: [[:alnum:].-]+/version: $$new_version/" ./deployments/helm/$(CHART_NAME)/Chart.yaml ; \
echo "Updated chart version to $$new_version"
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
.PHONY: package-chart publish-chart
package-chart:
@echo "Packaging chart..."
@helm package ./deployments/helm/$(CHART_NAME) -d ./deployments/helm/charts/packages/
@echo "Chart packaged successfully."
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
publish-chart:
@echo "Publishing chart..."
@helm repo index --merge ./deployments/helm/charts/index.yaml ./deployments/helm/charts/
@echo "Chart published successfully."
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
.PHONY: release-chart
release-chart: update-chart-version package-chart publish-chart
#-------------------------------------------------------------------------------
################################################################################
# BUILD DEPENDENCIES FOR CHART
################################################################################
## Location to install dependencies to
LOCALBIN ?= $(shell pwd)/bin
$(LOCALBIN):
mkdir -p $(LOCALBIN)
## Tool Binaries
KUSTOMIZE ?= $(LOCALBIN)/kustomize
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
ENVTEST ?= $(LOCALBIN)/setup-envtest
## Tool Versions
KUSTOMIZE_VERSION ?= v3.8.7
CONTROLLER_TOOLS_VERSION ?= v0.11.1
KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
.PHONY: kustomize
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary. If wrong version is installed, it will be removed before downloading.
$(KUSTOMIZE): $(LOCALBIN)
@if test -x $(LOCALBIN)/kustomize && ! $(LOCALBIN)/kustomize version | grep -q $(KUSTOMIZE_VERSION); then \
echo "$(LOCALBIN)/kustomize version is not expected $(KUSTOMIZE_VERSION). Removing it before installing."; \
rm -rf $(LOCALBIN)/kustomize; \
fi
test -s $(LOCALBIN)/kustomize || { curl -Ss $(KUSTOMIZE_INSTALL_SCRIPT) | bash -s -- $(subst v,,$(KUSTOMIZE_VERSION)) $(LOCALBIN); }
.PHONY: controller-gen
controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary. If wrong version is installed, it will be overwritten.
$(CONTROLLER_GEN): $(LOCALBIN)
test -s $(LOCALBIN)/controller-gen && $(LOCALBIN)/controller-gen --version | grep -q $(CONTROLLER_TOOLS_VERSION) || \
GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)
.PHONY: envtest
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
$(ENVTEST): $(LOCALBIN)
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest