-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
73 lines (58 loc) · 2.44 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
#######################################################################################
# SETUP EVERYTHING
#######################################################################################
__deps:
# Installing all required dependencies
cd user_app && npm install
cd ..
cd admin_app && npm install
cd ..
cd producer && pipenv install --dev
cd ..
cd consumer && pipenv install --dev
cd ..
__network:
# creating docker network
# NOTE: using a specific subnet
# in case we want to assign static IP later
docker network create --subnet=172.16.238.0/24 kafka_offshore
setup: __deps __network
#######################################################################################
# GET UP AND RUNNING
#######################################################################################
getup:
# docker-compose up, can scale more kafka-brokers and/or
# spark-worker using arguments: n=<int> s=<int>
# Eg: make up-scale k=2 s=3
docker-compose up -d --force-recreate --build --scale kafka=$(k) --scale spark-worker=$(s)
app_user:
echo "Running User Application to interact with Producer Backend API"
cd user_app && npm start
app_admin:
echo "Running Admin Application to view real-time changes from CouchDB"
cd admin_app && npm start
couch_cors:
npx add-cors-to-couchdb http://localhost:5984 -u admin -p 1234abc
#######################################################################################
# SUBMITTING JOBS
#######################################################################################
job_hosting_ip := "docker inspect -f \"{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}\" job_hosting"
spark_submit_command := spark-submit \
--class StreamJob \
--master spark://spark-master:7077 \
--deploy-mode cluster \
--executor-memory 1G \
--total-executor-cores 1 \
--num-executors 1
spark_docker_options := --network=kafka_offshore --name spark-job
assemble_scala_code := rm -rf spark_job/target/ && cd spark_job/ && sbt assembly && cd ..
spark_image = bitnami/spark:3
assemble_job:
$(assemble_scala_code)
job:
$(assemble_scala_code)
docker rm spark-job
docker run $(spark_docker_options) $(spark_image) $(spark_submit_command) http://$$(eval $(job_hosting_ip))/jobs/stream-job.jar
submit_job:
docker stop spark-job && docker rm spark-job
docker run $(spark_docker_options) $(spark_image) $(spark_submit_command) http://$$(eval $(job_hosting_ip))/jobs/stream-job.jar