forked from LesnyRumcajs/grpc_bench
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·56 lines (47 loc) · 1.43 KB
/
build.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
#!/bin/bash
./generate_ci.sh >.github/workflows/build.yml
export GRPC_REQUEST_SCENARIO=${GRPC_REQUEST_SCENARIO:-"complex_proto"}
export GRPC_IMAGE_NAME="${GRPC_IMAGE_NAME:-grpc_bench}"
## The list of benchmarks to build
BENCHMARKS_TO_BUILD="${@}"
## ...or use all the *_bench dirs by default
BENCHMARKS_TO_BUILD="${BENCHMARKS_TO_BUILD:-$(find . -maxdepth 1 -name '*_bench' -type d | sort)}"
# Setup the chosen scenario
if ! sh setup_scenario.sh $GRPC_REQUEST_SCENARIO false; then
echo "Scenario setup fiascoed."
exit 1
fi
branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
builds=""
for benchmark in ${BENCHMARKS_TO_BUILD}; do
benchmark=${benchmark##*/}
echo "==> Building Docker image for ${benchmark}..."
( (
DOCKER_BUILDKIT=1 docker image build \
--force-rm \
--pull \
--compress \
--file "${benchmark}/Dockerfile" \
--cache-from="$GRPC_IMAGE_NAME:${benchmark}-$GRPC_REQUEST_SCENARIO" \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--tag "$GRPC_IMAGE_NAME:${benchmark}-$GRPC_REQUEST_SCENARIO" \
. >"${benchmark}.tmp" 2>&1 &&
rm -f "${benchmark}.tmp" &&
echo "==> Done building ${benchmark}"
) || (
cat "${benchmark}.tmp"
rm -f "${benchmark}.tmp"
echo "==> Error building ${benchmark}"
exit 1
) ) &
builds="${builds} ${!}"
done
echo "==> Waiting for the builds to finish..."
for job in ${builds}; do
if ! wait "${job}"; then
wait
echo "Error building Docker image(s)"
exit 1
fi
done
echo "All done."