11# 🛠️ Flink for Java Workshop - Setup Makefile 🛠️
22
33# Colors for better readability
4- BLUE = \033[0;34m
5- GREEN = \033[0;32m
6- YELLOW = \033[1;33m
7- RED = \033[0;31m
8- BOLD = \033[1m
9- RESET = \033[0m
4+ BLUE: = $( shell printf " \033[0;34m")
5+ GREEN: = $( shell printf " \033[0;32m")
6+ YELLOW: = $( shell printf " \033[1;33m")
7+ RED: = $( shell printf " \033[0;31m")
8+ BOLD: = $( shell printf " \033[1m")
9+ RESET: = $( shell printf " \033[0m")
1010
1111# Emojis for better readability
1212CHECK =✅
@@ -17,33 +17,59 @@ ROCKET=🚀
1717COFFEE =☕
1818CLOCK =🕒
1919CLOUD =☁️
20+ STAR =⭐
21+ TERRAFORM =🌐
2022
2123# Default target
2224.PHONY : help
2325help :
2426 @echo " ${BLUE}${ROCKET} Flink for Java Workshop - Setup Makefile ${RESET} "
2527 @echo " "
2628 @echo " ${GREEN}${BOLD} Available targets:${RESET} "
27- @echo " ${YELLOW} setup-mac${RESET} - Install all required dependencies on macOS using Brewfile"
28- @echo " ${YELLOW} setup-linux${RESET} - Install all required dependencies on Linux"
29- @echo " ${YELLOW} setup-terraform${RESET} - Setup Terraform for Confluent Cloud"
30- @echo " ${YELLOW} terraform-init${RESET} - Initialize Terraform"
31- @echo " ${YELLOW} terraform-plan${RESET} - Plan Terraform changes"
32- @echo " ${YELLOW} terraform-apply${RESET} - Apply Terraform changes"
33- @echo " ${YELLOW} terraform-destroy${RESET} - Destroy Terraform-managed infrastructure"
34- @echo " ${YELLOW} terraform-output${RESET} - Generate cloud.properties from Terraform output"
35- @echo " ${YELLOW} tf-init${RESET} - Shorthand for terraform-init"
36- @echo " ${YELLOW} tf-plan${RESET} - Shorthand for terraform-plan"
37- @echo " ${YELLOW} tf-apply${RESET} - Shorthand for terraform-apply"
38- @echo " ${YELLOW} tf-destroy${RESET} - Shorthand for terraform-destroy"
39- @echo " ${YELLOW} tf-out${RESET} - Shorthand for terraform-output"
40- @echo " ${YELLOW} cc-setup${RESET} - Complete Confluent Cloud setup (init, plan, apply, output)"
41- @echo " ${YELLOW} cc-teardown${RESET} - Teardown Confluent Cloud infrastructure"
42- @echo " ${YELLOW} clean${RESET} - Clean up temporary files"
43- @echo " ${YELLOW} check-prereqs${RESET} - Check if all prerequisites are installed"
44- @echo " ${YELLOW} update-brew-deps${RESET} - Update Homebrew dependencies using Brewfile"
45- @echo " ${YELLOW} ci-checks${RESET} - Run CI checks locally"
46- @echo " ${YELLOW} docker-build${RESET} - Build Docker image locally"
29+ @echo " "
30+ @echo " ${YELLOW}${STAR} Environment Setup:${RESET} "
31+ @echo " ${BLUE}${INFO} 🔧 setup-mac${RESET} - Install all required dependencies on macOS using Brewfile"
32+ @echo " ${BLUE}${INFO} 🔧 setup-linux${RESET} - Install all required dependencies on Linux"
33+ @echo " ${BLUE}${INFO} 🔍 check-prereqs${RESET} - Check if all prerequisites are installed"
34+ @echo " ${BLUE}${INFO} 🔄 update-brew-deps${RESET} - Update Homebrew dependencies using Brewfile"
35+ @echo " "
36+ @echo " ${YELLOW}${STAR} Build & Run:${RESET} "
37+ @echo " ${BLUE}${INFO} 🏗️ build${RESET} - Build the entire project with Gradle"
38+ @echo " ${BLUE}${INFO} 🏗️ build-data-generator${RESET} - Build the Flink Data Generator"
39+ @echo " ${BLUE}${INFO} 🚀 run-streaming${RESET} - Run the Flink Streaming application"
40+ @echo " ${BLUE}${INFO} 🚀 run-sql${RESET} - Run the Flink SQL application"
41+ @echo " ${BLUE}${INFO} 🧪 ci-checks${RESET} - Run CI checks locally"
42+ @echo " "
43+ @echo " ${YELLOW}${STAR} Data Generator:${RESET} "
44+ @echo " ${BLUE}${INFO} 🚀 run-data-generator-local${RESET} - Run the Flink Data Generator in local environment"
45+ @echo " ${BLUE}${INFO} ☁️ run-data-generator-cloud${RESET} - Run the Flink Data Generator in cloud environment"
46+ @echo " ${BLUE}${INFO} 🚀 run-data-generator-with-props${RESET} - Run with custom properties (PROPS=path/to/properties)"
47+ @echo " "
48+ @echo " ${YELLOW}${STAR} Docker Management:${RESET} "
49+ @echo " ${BLUE}${INFO} 🐳 docker-up${RESET} - Start all containers"
50+ @echo " ${BLUE}${INFO} 🐳 docker-down${RESET} - Stop and remove all containers"
51+ @echo " ${BLUE}${INFO} 🐳 docker-restart${RESET} - Restart all containers"
52+ @echo " ${BLUE}${INFO} 🐳 docker-ps${RESET} - List running containers and their status"
53+ @echo " ${BLUE}${INFO} 🐳 docker-logs${RESET} - View logs (optionally for a specific service with SERVICE=name)"
54+ @echo " ${BLUE}${INFO} 🐳 docker-build${RESET} - Build Docker image locally"
55+ @echo " "
56+ @echo " ${YELLOW}${STAR} Terraform & Confluent Cloud:${RESET} "
57+ @echo " ${BLUE}${INFO} ☁️ setup-terraform${RESET} - Setup Terraform for Confluent Cloud (using HashiCorp's official tap)"
58+ @echo " ${BLUE}${INFO} ☁️ terraform-init${RESET} - Initialize Terraform"
59+ @echo " ${BLUE}${INFO} ☁️ terraform-plan${RESET} - Plan Terraform changes"
60+ @echo " ${BLUE}${INFO} ☁️ terraform-apply${RESET} - Apply Terraform changes"
61+ @echo " ${BLUE}${INFO} ☁️ terraform-destroy${RESET} - Destroy Terraform-managed infrastructure"
62+ @echo " ${BLUE}${INFO} ☁️ terraform-output${RESET} - Generate cloud.properties from Terraform output"
63+ @echo " ${BLUE}${INFO} ☁️ cc-setup${RESET} - Complete Confluent Cloud setup (init, plan, apply, output)"
64+ @echo " ${BLUE}${INFO} ☁️ cc-teardown${RESET} - Teardown Confluent Cloud infrastructure"
65+ @echo " ${BLUE}${INFO} ☁️ tf-init${RESET} - Shorthand for terraform-init"
66+ @echo " ${BLUE}${INFO} ☁️ tf-plan${RESET} - Shorthand for terraform-plan"
67+ @echo " ${BLUE}${INFO} ☁️ tf-apply${RESET} - Shorthand for terraform-apply"
68+ @echo " ${BLUE}${INFO} ☁️ tf-destroy${RESET} - Shorthand for terraform-destroy"
69+ @echo " ${BLUE}${INFO} ☁️ tf-out${RESET} - Shorthand for terraform-output"
70+ @echo " "
71+ @echo " ${YELLOW}${STAR} Cleanup:${RESET} "
72+ @echo " ${BLUE}${INFO} 🧹 clean${RESET} - Clean up temporary files"
4773 @echo " "
4874 @echo " ${BLUE}${INFO} For more information, see README.adoc${RESET} "
4975
@@ -57,10 +83,8 @@ update-brew-deps:
5783 fi
5884 @echo " ${BLUE}${INFO} Updating Homebrew...${RESET} "
5985 brew update
60- @echo " ${BLUE}${INFO} Tapping Confluent repository...${RESET} "
61- brew tap confluentinc/tap
6286 @echo " ${BLUE}${INFO} Updating dependencies from Brewfile...${RESET} "
63- brew bundle || echo " ${YELLOW}${WARNING} Some Brewfile installations failed. Check output for details.${RESET} "
87+ brew bundle || { printf " ${YELLOW}${WARNING} Some Brewfile installations failed. Check output for details.${RESET} \n " ; }
6488 @echo " ${GREEN}${CHECK} Homebrew dependencies updated!${RESET} "
6589
6690# Check prerequisites
@@ -123,17 +147,14 @@ check-prereqs:
123147.PHONY : setup-mac
124148setup-mac :
125149 @echo " ${BLUE}${ROCKET} Setting up dependencies on macOS...${RESET} "
126- @echo " ${YELLOW}${INFO} Installing/Updating Homebrew packages using Brewfile...${RESET} "
127150 @if ! command -v brew > /dev/null 2>&1 ; then \
128151 echo " ${RED}${ERROR} Homebrew is not installed. Please install it first: https://brew.sh${RESET} " ; \
129152 exit 1; \
130153 fi
131154 @echo " ${BLUE}${INFO} Updating Homebrew...${RESET} "
132155 brew update
133- @echo " ${BLUE}${INFO} Tapping Confluent repository...${RESET} "
134- brew tap confluentinc/tap
135156 @echo " ${BLUE}${INFO} Installing dependencies from Brewfile...${RESET} "
136- brew bundle || echo " ${YELLOW}${WARNING} Some Brewfile installations failed. Check output for details.${RESET} "
157+ @ brew bundle || { printf " ${YELLOW}${WARNING} Some Brewfile installations failed. Check output for details.${RESET} \n " ; }
137158 @echo " ${BLUE}${INFO} Checking for SDKMAN installation...${RESET} "
138159 @if [ -d " $$ HOME/.sdkman" ]; then \
139160 echo " ${GREEN}${CHECK} SDKMAN is already installed${RESET} " ; \
@@ -170,7 +191,7 @@ setup-linux:
170191 sudo usermod -aG docker $USER
171192 # Install Terraform
172193 @echo " ${BLUE}${INFO} Installing Terraform...${RESET} "
173- sudo apt-get install -y software-properties-common
194+ sudo apt-get install -y software-properties-common gnupg
174195 wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
175196 echo " deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $( lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
176197 sudo apt-get update
@@ -195,7 +216,7 @@ setup-linux:
195216.PHONY : setup-terraform
196217setup-terraform :
197218 @echo " ${BLUE}${CLOUD} Setting up Terraform for Confluent Cloud...${RESET} "
198- @echo " ${YELLOW}${INFO} Please enter your Confluent Cloud credentials: ${RESET} "
219+ @echo " ${YELLOW}${INFO} Please enter your Confluent Cloud credentials and organization ID. This will be used to create a new environment and service account. ${RESET} "
199220 @read -p " Confluent Cloud API Key: " API_KEY; \
200221 read -p " Confluent Cloud API Secret: " API_SECRET; \
201222 echo " export CONFLUENT_CLOUD_API_KEY=$$ API_KEY" > .env; \
@@ -311,22 +332,41 @@ run-sql:
311332 @echo " ${BLUE}${ROCKET} Running Flink SQL application...${RESET} "
312333 ./gradlew :flink-sql:run
313334
314- # Start local Docker environment
315- .PHONY : start-docker
316- start-docker :
317- @echo " ${BLUE}${ROCKET} Starting Docker environment...${RESET} "
318- docker-compose up -d
319- @echo " ${GREEN}${CHECK} Docker environment started!${RESET} "
335+ # Docker Compose targets
336+ .PHONY : docker-up docker-down docker-ps docker-logs docker-restart
337+
338+ docker-up :
339+ @echo " ${BLUE}${ROCKET} Starting Docker containers...${RESET} "
340+ @if ! command -v docker > /dev/null 2>&1 ; then \
341+ echo " ${RED}${ERROR} Docker is not installed${RESET} " ; \
342+ exit 1; \
343+ fi
344+ docker compose up -d
345+ @echo " ${GREEN}${CHECK} Docker containers started successfully!${RESET} "
320346 @echo " ${YELLOW}${INFO} Kafka is available at localhost:29092${RESET} "
321347 @echo " ${YELLOW}${INFO} Schema Registry is available at http://localhost:8081${RESET} "
322- @echo " ${YELLOW}${INFO} Flink Dashboard is available at http://localhost:8080${RESET} "
323348
324- # Stop local Docker environment
325- .PHONY : stop-docker
326- stop-docker :
327- @echo " ${BLUE}${INFO} Stopping Docker environment...${RESET} "
328- docker-compose down
329- @echo " ${GREEN}${CHECK} Docker environment stopped!${RESET} "
349+ docker-down :
350+ @echo " ${BLUE}${INFO} Stopping Docker containers...${RESET} "
351+ docker compose down
352+ @echo " ${GREEN}${CHECK} Docker containers stopped successfully!${RESET} "
353+
354+ docker-ps :
355+ @echo " ${BLUE}${INFO} Listing running Docker containers...${RESET} "
356+ docker compose ps
357+
358+ docker-logs :
359+ @echo " ${BLUE}${INFO} Showing Docker container logs...${RESET} "
360+ @if [ -z " $( SERVICE) " ]; then \
361+ docker compose logs -f; \
362+ else \
363+ docker compose logs -f $(SERVICE ) ; \
364+ fi
365+
366+ docker-restart :
367+ @echo " ${BLUE}${ROCKET} Restarting Docker containers...${RESET} "
368+ docker compose restart
369+ @echo " ${GREEN}${CHECK} Docker containers restarted successfully!${RESET} "
330370
331371# Run CI checks locally
332372.PHONY : ci-checks
@@ -357,6 +397,35 @@ docker-build:
357397 @echo " ${GREEN}${CHECK} Docker image built successfully!${RESET} "
358398 @echo " ${YELLOW}${INFO} Run with: docker run -it flink-for-java-workshop:local${RESET} "
359399
400+ # Flink Data Generator targets
401+ .PHONY : build-data-generator
402+ build-data-generator :
403+ @echo " ${BLUE}${ROCKET} Building Flink Data Generator...${RESET} "
404+ ./gradlew :flink-data-generator:build
405+ @echo " ${GREEN}${CHECK} Flink Data Generator built successfully!${RESET} "
406+
407+ .PHONY : run-data-generator-local
408+ run-data-generator-local :
409+ @echo " ${BLUE}${ROCKET} Running Flink Data Generator in local environment...${RESET} "
410+ ./gradlew :flink-data-generator:run --args=" --env local"
411+ @echo " ${GREEN}${CHECK} Flink Data Generator completed!${RESET} "
412+
413+ .PHONY : run-data-generator-cloud
414+ run-data-generator-cloud :
415+ @echo " ${BLUE}${CLOUD} Running Flink Data Generator in cloud environment...${RESET} "
416+ ./gradlew :flink-data-generator:run --args=" --env cloud"
417+ @echo " ${GREEN}${CHECK} Flink Data Generator completed!${RESET} "
418+
419+ .PHONY : run-data-generator-with-props
420+ run-data-generator-with-props :
421+ @echo " ${BLUE}${ROCKET} Running Flink Data Generator with custom properties...${RESET} "
422+ @if [ -z " $( PROPS) " ]; then \
423+ echo " ${RED}${ERROR} Please specify properties file with PROPS=path/to/properties.${RESET} " ; \
424+ exit 1; \
425+ fi
426+ ./gradlew :flink-data-generator:run --args=" --properties $( PROPS) "
427+ @echo " ${GREEN}${CHECK} Flink Data Generator completed!${RESET} "
428+
360429# Clean up
361430.PHONY : clean
362431clean :
0 commit comments