-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·54 lines (45 loc) · 1.22 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
#!/bin/bash
# Any command that fails will immediately exit
set -e
# Usage function to display help documentation
function usage {
echo "Usage: $0 [OPTIONS]"
echo -e "\nOptions:"
echo "-h|--help Display help"
echo "--multiplatform Enable multiplatform build"
echo -e "\nThis script builds a Flutter web app and a backend API. By default, it builds a Docker image for the API using jibDockerBuild task. If the --multiplatform option is provided, it uses the jib task with -Pmultiplatform_build=true instead."
exit $1
}
multiplatform=false
# Parse command line options
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-h|--help)
usage 0
;;
--multiplatform)
multiplatform=true
shift # past value
;;
*)
echo "Unknown option: $key"
usage 1
;;
esac
done
# Require Flutter
# Checks for required commands
command -v flutter >/dev/null 2>&1 || { echo >&2 "Flutter required but it's not installed. Aborting."; exit 1; }
pushd ui
flutter build web
popd
cp -R ui/build/web/* api/static/
pushd api
if [[ "$multiplatform" == "true" ]]; then
./gradlew clean jib -Pmultiplatform_build=true
else
./gradlew clean jibDockerBuild
fi
popd
exit 0;