-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
352 lines (318 loc) · 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
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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
# -----------------------------------------------------------------------------
# MAKEFILE RUNNING COMMAND
# -----------------------------------------------------------------------------
# Author : DevOps Engineer ([email protected])
# License : Apache v2
# -----------------------------------------------------------------------------
# Notes:
# use [TAB] instead [SPACE]
export PATH_APP=`pwd`
export PATH_WORKSPACE="src"
export PATH_SCRIPT="scripts"
export PATH_COMPOSE="compose"
export PATH_DOCKER="."
export PROJECT_NAME="nifi"
export TF_PATH="terraform/environment/providers/aws/infra"
export TF_CORE="$(TF_PATH)/core"
export TF_RESOURCES="$(TF_PATH)/resources"
export TF_STATE="$(TF_PATH)/tfstate"
export TF_MODULES="terraform/modules/providers/aws"
export CI_REGISTRY ?= $(ARGS).dkr.ecr.ap-southeast-1.amazonaws.com
export CI_PROJECT_PATH ?= devopscorner
export CI_PROJECT_NAME ?= nifi
IMAGE = $(CI_REGISTRY)/${CI_PROJECT_PATH}/${CI_PROJECT_NAME}
DIR = $(shell pwd)
VERSION ?= 1.3.0
export BASE_IMAGE=ubuntu
export UBUNTU_VERSION=22.04
export NIFI_VERSION=1.18.0
export NIFI_REGISTRY_VERSION=1.18.0
# =============== #
# GET MODULES #
# =============== #
.PHONY: sub-officials sub-community sub-all codebuild-modules
sub-officials:
@echo "=============================================================="
@echo " Task : Get Official Submodules "
@echo " Date/Time : `date` "
@echo "=============================================================="
@mkdir -p $(TF_MODULES)/officials
@cd $(PATH_APP) && ./get-officials.sh
sub-community:
@echo "=============================================================="
@echo " Task : Get Community Submodules "
@echo " Date/Time : `date` "
@echo "=============================================================="
@mkdir -p $(TF_MODULES)/community
@cd $(PATH_APP) && ./get-community.sh
sub-all:
@make sub-officials
@echo ''
@make sub-community
@echo ''
@echo '---'
@echo '- ALL DONE -'
codebuild-modules:
@echo "=============================================================="
@echo " Task : Get CodeBuild Modules "
@echo " Date/Time : `date` "
@echo "=============================================================="
@./get-modules-codebuild.sh
# ==================== #
# CLONE REPOSITORY #
# ==================== #
.PHONY: git-clone
git-clone:
@echo "=============================================================="
@echo " Task : Clone Repository Sources "
@echo " Date/Time : `date` "
@echo "=============================================================="
@./git-clone.sh $(SOURCE) $(TARGET)
@echo '- DONE -'
# ================== #
# DOCKER-COMPOSE #
# ================== #
.PHONY: run stop remove
run:
@echo "=============================================================="
@echo " Task : Docker Container "
@echo " Date/Time : `date`"
@echo "=============================================================="
@./run-docker.sh
@echo '- DONE -'
stop:
@echo "=============================================================="
@echo " Task : Stopping Docker Container "
@echo " Date/Time : `date`"
@echo "=============================================================="
@docker-compose -f ${PATH_COMPOSE}/nifi-psql.yml stop
@echo '- DONE -'
remove:
@echo "=============================================================="
@echo " Task : Remove Docker Container "
@echo " Date/Time : `date`"
@echo "=============================================================="
@docker-compose -f ${PATH_COMPOSE}/nifi-psql.yml down
@echo '- DONE -'
# =================== #
# BUILD CONTAINER #
# =================== #
.PHONY: dockerhub-build-nifi dockerhub-build-nifi-registry ecr-build-nifi ecr-build-nifi-registry
# ./dockerhub-build.sh Dockerfile [DOCKERHUB_IMAGE_PATH] [alpine|ubuntu|codebuild] [version|latest|tags] [custom-tags]
dockerhub-build-nifi:
@echo "=============================================================="
@echo " Task : Create Container Image Nifi (DockerHub) "
@echo " Date/Time : `date` "
@echo "=============================================================="
@sh ./dockerhub-build.sh Dockerfile-Nifi devopscorner/nifi ubuntu ${NIFI_VERSION}
@echo '- DONE -'
dockerhub-build-nifi-registry:
@echo "=============================================================="
@echo " Task : Create Container Image Nifi Registry (DockerHub) "
@echo " Date/Time : `date` "
@echo "=============================================================="
@sh ./dockerhub-build.sh Dockerfile-Nifi-Registry devopscorner/nifi-registry ubuntu ${NIFI_REGISTRY_VERSION}
@echo '- DONE -'
# ./ecr-build.sh [AWS_ACCOUNT] Dockerfile [ECR_PATH] [alpine|ubuntu|codebuild] [version|latest|tags] [custom-tags]
ecr-build-nifi:
@echo "=============================================================="
@echo " Task : Create Container Image Nifi (ECR) "
@echo " Date/Time : `date` "
@echo "=============================================================="
@sh ./ecr-build.sh $(ARGS) Dockerfile-Nifi $(CI_PATH) ubuntu ${NIFI_VERSION}
@echo '- DONE -'
ecr-build-nifi-registry:
@echo "=============================================================="
@echo " Task : Create Container Image Nifi Registry (ECR) "
@echo " Date/Time : `date` "
@echo "=============================================================="
@sh ./ecr-build.sh $(ARGS) Dockerfile-Nifi-Registry $(CI_PATH) ubuntu ${NIFI_REGISTRY_VERSION}
@echo '- DONE -'
# ================== #
# TAGS CONTAINER #
# ================== #
.PHONY: dockerhub-tag-nifi dockerhub-tag-nifi-registry ecr-tag-nifi ecr-tag-nifi-registry
# ./dockerhub-tag.sh [DOCKERHUB_IMAGE_PATH] [alpine|ubuntu] [version|latest|tags] [custom-tags]
dockerhub-tag-nifi:
@echo "=============================================================="
@echo " Task : Set Tags Image Nifi (DockerHub) "
@echo " Date/Time : `date` "
@echo "=============================================================="
@sh ./dockerhub-tag.sh $(CI_PATH) ubuntu ${NIFI_VERSION}
@echo '- DONE -'
dockerhub-tag-nifi-registry:
@echo "=============================================================="
@echo " Task : Set Tags Image Nifi Registry (DockerHub) "
@echo " Date/Time : `date` "
@echo "=============================================================="
@sh ./dockerhub-tag.sh $(CI_PATH) ubuntu ${NIFI_REGISTRY_VERSION}
@echo '- DONE -'
# ./ecr-tag.sh [AWS_ACCOUNT] [ECR_PATH] [alpine|ubuntu] [version|latest|tags] [custom-tags]
ecr-tag-nifi:
@echo "=============================================================="
@echo " Task : Set Tags Image Nifi (ECR) "
@echo " Date/Time : `date` "
@echo "=============================================================="
@sh ./ecr-tag.sh $(ARGS) $(CI_PATH) ubuntu ${NIFI_VERSION}
@echo '- DONE -'
ecr-tag-nifi-registry:
@echo "=============================================================="
@echo " Task : Set Tags Image Nifi Registry (ECR) "
@echo " Date/Time : `date` "
@echo "=============================================================="
@sh ./ecr-tag.sh $(ARGS) $(CI_PATH) ubuntu ${NIFI_REGISTRY_VERSION}
@echo '- DONE -'
# ================== #
# PUSH CONTAINER #
# ================== #
.PHONY: dockerhub-push-nifi dockerhub-push-nifi-registry ecr-push-nifi ecr-push-nifi-registry
# ./dockerhub-push.sh [DOCKERHUB_IMAGE_PATH] [alpine|ubuntu|codebuild|version|latest|tags|custom-tags]
dockerhub-push-nifi:
@echo "=============================================================="
@echo " Task : Push Container Image Nifi (DockerHub) "
@echo " Date/Time : `date` "
@echo "=============================================================="
@sh ./dockerhub-push.sh $(CI_PATH) ubuntu
@sh ./dockerhub-push.sh $(CI_PATH) latest
@sh ./dockerhub-push.sh $(CI_PATH) ${NIFI_VERSION}
@echo '- DONE -'
dockerhub-push-nifi-registry:
@echo "=============================================================="
@echo " Task : Push Container Image Nifi Registry (DockerHub) "
@echo " Date/Time : `date` "
@echo "=============================================================="
@sh ./dockerhub-push.sh $(CI_PATH) ubuntu
@sh ./dockerhub-push.sh $(CI_PATH) latest
@sh ./dockerhub-push.sh $(CI_PATH) ${NIFI_REGISTRY_VERSION}
@echo '- DONE -'
# ./ecr-push.sh [AWS_ACCOUNT] [ECR_PATH] [alpine|ubuntu|codebuild|version|latest|tags|custom-tags]
ecr-push-nifi:
@echo "=============================================================="
@echo " Task : Push Container Image Nifi (ECR) "
@echo " Date/Time : `date` "
@echo "=============================================================="
@sh ./ecr-push.sh $(ARGS) $(CI_PATH) ubuntu
@sh ./ecr-push.sh $(ARGS) $(CI_PATH) latest
@sh ./ecr-push.sh $(ARGS) $(CI_PATH) ${NIFI_VERSION}
@echo '- DONE -'
ecr-push-nifi-registry:
@echo "=============================================================="
@echo " Task : Push Container Image Nifi Registry (ECR) "
@echo " Date/Time : `date` "
@echo "=============================================================="
@sh ./ecr-push.sh $(ARGS) $(CI_PATH) ubuntu
@sh ./ecr-push.sh $(ARGS) $(CI_PATH) latest
@sh ./ecr-push.sh $(ARGS) $(CI_PATH) ${NIFI_REGISTRY_VERSION}
@echo '- DONE -'
# ================== #
# PULL CONTAINER #
# ================== #
.PHONY: pull-nifi pull-nifi-registry
# ./ecr-pull.sh [AWS_ACCOUNT] [ECR_PATH] [alpine|ubuntu|codebuild|version|latest|tags|custom-tags]
ecr-pull-nifi:
@echo "=============================================================="
@echo " Task : Pull Container Image Nifi (ECR) "
@echo " Date/Time : `date` "
@echo "=============================================================="
@sh ./ecr-pull.sh $(ARGS) $(CI_PATH) ubuntu
@sh ./ecr-pull.sh $(ARGS) $(CI_PATH) latest
@sh ./ecr-pull.sh $(ARGS) $(CI_PATH) ${NIFI_VERSION}
@echo '- DONE -'
ecr-pull-nifi-registry:
@echo "=============================================================="
@echo " Task : Pull Container Image Nifi Registry (ECR) "
@echo " Date/Time : `date` "
@echo "=============================================================="
@sh ./ecr-pull.sh $(ARGS) $(CI_PATH) ubuntu
@sh ./ecr-pull.sh $(ARGS) $(CI_PATH) latest
@sh ./ecr-pull.sh $(ARGS) $(CI_PATH) ${NIFI_REGISTRY_VERSION}
@echo '- DONE -'
# =========================== #
# PROVISIONING INFRA CORE #
# =========================== #
.PHONY: tf-core-init tf-core-create-workspace tf-core-select-workspace tf-core-plan tf-core-apply
tf-core-init:
@echo "=============================================================="
@echo " Task : Terraform Init "
@echo " Date/Time : `date` "
@echo "=============================================================="
@cd $(TF_CORE) && terraform init $(ARGS)
@echo '- DONE -'
tf-core-create-workspace:
@echo "=============================================================="
@echo " Task : Terraform Create Workspace "
@echo " Date/Time : `date` "
@echo "=============================================================="
@cd $(TF_CORE) && terraform workspace new $(ARGS)
@echo '- DONE -'
tf-core-select-workspace:
@echo "=============================================================="
@echo " Task : Terraform Select Workspace "
@echo " Date/Time : `date` "
@echo "=============================================================="
@cd $(TF_CORE) && terraform workspace select $(ARGS)
@echo '- DONE -'
tf-core-plan:
@echo "=============================================================="
@echo " Task : Terraform Plan Provisioning "
@echo " Date/Time : `date` "
@echo "=============================================================="
@cd $(TF_CORE) && terraform plan $(ARGS)
@echo '- DONE -'
tf-core-apply:
@echo "=============================================================="
@echo " Task : Provisioning Terraform "
@echo " Date/Time : `date` "
@echo "=============================================================="
@cd $(TF_CORE) && terraform apply -auto-approve
@echo '- DONE -'
# ================================ #
# PROVISIONING RESOURCES INFRA #
# ================================ #
.PHONY: tf-infra-init tf-infra-create-workspace tf-infra-select-workspace tf-infra-plan tf-infra-apply tf-infra-resource
tf-infra-init:
@echo "=============================================================="
@echo " Task : Terraform Init "
@echo " Date/Time : `date` "
@echo "=============================================================="
@cd $(TF_RESOURCES)/$(INFRA_RESOURCES) && terraform init $(ARGS)
@echo '- DONE -'
tf-infra-create-workspace:
@echo "=============================================================="
@echo " Task : Terraform Create Workspace "
@echo " Date/Time : `date` "
@echo "=============================================================="
@cd $(TF_RESOURCES)/$(INFRA_RESOURCES) && terraform workspace new $(ARGS)
@echo '- DONE -'
tf-infra-select-workspace:
@echo "=============================================================="
@echo " Task : Terraform Select Workspace "
@echo " Date/Time : `date` "
@echo "=============================================================="
@cd $(TF_RESOURCES)/$(INFRA_RESOURCES) && terraform workspace select $(ARGS)
@echo '- DONE -'
tf-infra-plan:
@echo "=============================================================="
@echo " Task : Terraform Plan Provisioning "
@echo " Date/Time : `date` "
@echo "=============================================================="
@cd $(TF_RESOURCES)/$(INFRA_RESOURCES) && terraform plan $(ARGS)
@echo '- DONE -'
tf-infra-apply:
@echo "=============================================================="
@echo " Task : Provisioning Terraform "
@echo " Date/Time : `date` "
@echo "=============================================================="
@cd $(TF_RESOURCES)/$(INFRA_RESOURCES) && terraform apply -auto-approve $(ARGS)
@echo '- DONE -'
# =============================== #
# PROVISIONING SPESIFIC INFRA #
# =============================== #
.PHONY: tf-infra-resource
tf-infra-resource:
@echo "=============================================================="
@echo " Task : Terraform Command $(ARGS)"
@echo " Date/Time : `date` "
@echo "=============================================================="
@cd $(TF_RESOURCES)/$(INFRA_RESOURCES) && terraform $(ARGS)
@echo '- DONE -'