-
Notifications
You must be signed in to change notification settings - Fork 169
/
Copy pathgenerate-docker-compose-resources.sh
executable file
·182 lines (142 loc) · 6.22 KB
/
generate-docker-compose-resources.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
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
#!/bin/bash -ex
# Create the deploy/docker-compose files for each version of each of the Quarkus services
# Then add on the ui-super-heroes
INPUT_DIR=src/main/docker-compose
OUTPUT_DIR=deploy/docker-compose
create_output_file() {
local output_file=$1
echo "Creating output file: $output_file"
touch $output_file
# This is here because of
# https://github.com/quarkusio/quarkus-super-heroes/issues/299
echo '#######################################################################' >> $output_file
echo '# THIS FILE IS AUTOMATICALLY GENERATED DURING CI/CD.' >> $output_file
echo '# ANY LOCAL CHANGES YOU MAKE SHOULD NOT BE COMMITTED TO SOURCE CONTROL.' >> $output_file
echo '#######################################################################' >> $output_file
echo '' >> $output_file
echo 'version: "3"' >> $output_file
echo 'services:' >> $output_file
}
create_project_output() {
local project=$1
local filename=$2
local versionFilename=$3
local infra_input_file_name="infra.yml"
local infra_input_file="$project/$INPUT_DIR/$infra_input_file_name"
local input_file_name="${filename}.yml"
local version_file_name="${versionFilename}.yml"
local all_apps_output_file="$OUTPUT_DIR/$version_file_name"
local project_input_file="$project/$INPUT_DIR/$input_file_name"
local project_output_file="$project/$OUTPUT_DIR/$input_file_name"
echo ""
echo "-----------------------------------------"
echo "Creating output for project = $project filename = $filename version_file_name = $version_file_name"
if [[ ! -d "$project/$OUTPUT_DIR" ]]; then
mkdir -p $project/$OUTPUT_DIR
fi
if [[ ! -f "$all_apps_output_file" ]]; then
create_output_file $all_apps_output_file
fi
if [[ -f "$project_output_file" ]]; then
rm -rf $project_output_file
fi
create_output_file $project_output_file
if [[ -f "$infra_input_file" ]]; then
cat $infra_input_file >> $project_output_file
fi
if [[ -f "$project_input_file" ]]; then
cat $project_input_file >> $project_output_file
if [[ "$project" == "event-statistics" || "$project" == "ui-super-heroes" ]]; then
cat $project_input_file >> $all_apps_output_file
fi
fi
if [[ "$project" == "rest-fights" ]]; then
# Need to process/create the downstream version
# With the rest-villains/rest-heroes apps & their dependencies
local downstream_project_output_file="$project/$OUTPUT_DIR/${filename}-all-downstream.yml"
rm -rf $downstream_project_output_file
create_output_file $downstream_project_output_file
if [[ -d "$project/deploy/db-init" ]]; then
cp -r $project/deploy/db-init deploy
fi
if [[ -f "$infra_input_file" ]]; then
cat $infra_input_file >> $downstream_project_output_file
cat $infra_input_file | sed 's/..\/..\/..\//..\/..\//g' >> $all_apps_output_file
fi
if [[ -f "$project_input_file" ]]; then
cat $project_input_file >> $downstream_project_output_file
cat $project_input_file >> $all_apps_output_file
fi
if [[ -f "rest-villains/$INPUT_DIR/$infra_input_file_name" ]]; then
cat rest-villains/$INPUT_DIR/$infra_input_file_name >> $downstream_project_output_file
cat rest-villains/$INPUT_DIR/$infra_input_file_name | sed 's/..\/..\/..\//..\/..\//g' >> $all_apps_output_file
fi
if [[ -f "rest-heroes/$INPUT_DIR/$infra_input_file_name" ]]; then
cat rest-heroes/$INPUT_DIR/$infra_input_file_name >> $downstream_project_output_file
cat rest-heroes/$INPUT_DIR/$infra_input_file_name | sed 's/..\/..\/..\//..\/..\//g' >> $all_apps_output_file
fi
if [[ -f "rest-narration/$INPUT_DIR/$infra_input_file_name" ]]; then
cat rest-narration/$INPUT_DIR/$infra_input_file_name >> $downstream_project_output_file
cat rest-narration/$INPUT_DIR/$infra_input_file_name | sed 's/..\/..\/..\//..\/..\//g' >> $all_apps_output_file
fi
if [[ -f "grpc-locations/$INPUT_DIR/$infra_input_file_name" ]]; then
cat grpc-locations/$INPUT_DIR/$infra_input_file_name >> $downstream_project_output_file
cat grpc-locations/$INPUT_DIR/$infra_input_file_name | sed 's/..\/..\/..\//..\/..\//g' >> $all_apps_output_file
fi
if [[ -f "rest-villains/$INPUT_DIR/$input_file_name" ]]; then
cat rest-villains/$INPUT_DIR/$input_file_name >> $downstream_project_output_file
cat rest-villains/$INPUT_DIR/$input_file_name >> $all_apps_output_file
fi
if [[ -f "rest-heroes/$INPUT_DIR/$input_file_name" ]]; then
cat rest-heroes/$INPUT_DIR/$input_file_name >> $downstream_project_output_file
cat rest-heroes/$INPUT_DIR/$input_file_name >> $all_apps_output_file
fi
if [[ -f "rest-narration/$INPUT_DIR/$input_file_name" ]]; then
cat rest-narration/$INPUT_DIR/$input_file_name >> $downstream_project_output_file
cat rest-narration/$INPUT_DIR/$input_file_name >> $all_apps_output_file
fi
if [[ -f "grpc-locations/$INPUT_DIR/$input_file_name" ]]; then
cat grpc-locations/$INPUT_DIR/$input_file_name >> $downstream_project_output_file
cat grpc-locations/$INPUT_DIR/$input_file_name >> $all_apps_output_file
fi
fi
}
create_monitoring() {
local monitoring_name="monitoring"
echo ""
echo "-----------------------------------------"
echo "Creating monitoring"
mkdir -p $OUTPUT_DIR/$monitoring_name
cp $monitoring_name/config/*.yml $OUTPUT_DIR/$monitoring_name
cp $monitoring_name/docker-compose/*.yml $OUTPUT_DIR
}
rm -rf $OUTPUT_DIR/*.yml
rm -rf $OUTPUT_DIR/monitoring
rm -rf deploy/db-init
for project in "grpc-locations" "rest-narration" "rest-villains" "rest-heroes" "rest-fights" "event-statistics" "ui-super-heroes"
do
rm -rf $project/$OUTPUT_DIR/*.yml
kinds=("" "native-")
for kind in "${kinds[@]}"
do
# Keeping this if/else here for the future when we might want to build multiple java versions
if [[ "$kind" == "native-" ]]; then
javaVersions=(21)
else
javaVersions=(21)
# javaVersions=(11 21)
fi
for javaVersion in ${javaVersions[@]}
do
if [[ "$kind" == "native-" ]]; then
versionFilename="native"
else
versionFilename="${kind}java${javaVersion}"
fi
filename=$versionFilename
create_project_output $project $filename $versionFilename
done
done
done
# Now handle the monitoring
create_monitoring