-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun.sh
executable file
·56 lines (48 loc) · 1.53 KB
/
run.sh
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
#!/usr/bin/env bash
data_caterer_version=$(grep dataCatererVersion gradle.properties | cut -d= -f2)
if [[ -s ".tmp_prev_class_name" ]]; then
prev_class_name=$(cat .tmp_prev_class_name)
else
prev_class_name='DocumentationPlanRun'
fi
if [[ $# -eq 0 ]]; then
read -p "Class name of plan to run [$prev_class_name]: " class_name
curr_class_name=${class_name:-$prev_class_name}
else
curr_class_name=$1
fi
full_class_name=io.github.datacatering.plan.$curr_class_name
echo -n "$curr_class_name" > .tmp_prev_class_name
image_suffix="-basic"
additional_env_vars=""
if [[ "$curr_class_name" == *"Advanced"* ]]; then
if [[ -z "$DATA_CATERING_API_KEY" ]]; then
image_suffix=""
else
image_suffix="-trial"
additional_env_vars=" -e API_KEY=$DATA_CATERING_API_KEY"
fi
fi
echo "Building jar with plan run"
./gradlew clean build
if [[ $? -ne 0 ]]; then
echo "Failed to build!"
exit 1
fi
docker network create --driver bridge docker_default || true
echo "Running Data Caterer via docker, version: $data_caterer_version"
DOCKER_CMD=(
docker run -p 4040:4040
-v "$(pwd)/build/libs/data-caterer-example-0.1.0.jar:/opt/spark/jars/data-caterer.jar"
-v "$(pwd)/docker/sample:/opt/app/data"
-v "$(pwd)/docker/sample/tracking:/opt/app/record-tracking"
-v "$(pwd)/docker/mount:/opt/app/mount"
-e "PLAN_CLASS=$full_class_name"
-e "DRIVER_MEMORY=2g"
-e "EXECUTOR_MEMORY=2g"
"$additional_env_vars"
--network "docker_default"
datacatering/data-caterer"$image_suffix":"$data_caterer_version"
)
eval "${DOCKER_CMD[@]}"
echo "Finished!"