-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build_module.sh
executable file
·64 lines (55 loc) · 1.49 KB
/
build_module.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
#!/bin/bash
CURRENT_DIR=$(basename `pwd`)
if [ ! "${CURRENT_DIR}" = "composable-rss-app" ]
then
echo "Wrong dir: ${CURRENT_DIR}";
exit;
fi
echo "Current dir: ${CURRENT_DIR}"
DEBUG="false"
DEBUG_PORT=
while [[ $# -gt 0 ]]; do
case $1 in
-d|--debug)
if [[ $# -lt 2 || $2 == -* ]]; then
echo "Error: Missing debug port number after --debug"
echo "Usage: $0 <module_name> [--debug <port_number>]"
exit 1
fi
DEBUG="true"
DEBUG_PORT="$2"
shift 2
;;
*)
if [ ! -z "${MODULE_NAME}" ]; then
echo "Usage: $0 <module_name> [--debug <port_number>]"
echo " <module_name>: Name of the module (required)"
echo " --debug <port_number>: Enable debugging with the specified port number (optional)"
exit 1
fi
MODULE_NAME="$1"
shift
;;
esac
done
if [ "${DEBUG}" == "true" ]
then
AGENT_ARG="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:${DEBUG_PORT}";
TAG_NAME="latest-debug"
else
AGENT_ARG=
TAG_NAME="latest-local"
fi
echo "Building module: ${MODULE_NAME}, tag name: ${TAG_NAME}, isDebug: ${DEBUG}, agent args: ${AGENT_ARG}"
# change to the module dir
cd ${MODULE_NAME}
# build the artifacts via gradle
./gradlew clean build
# build the docker image with the updated artifacts
docker build \
--build-arg JAR_FILE=build/libs/*.jar \
--build-arg AGENT_ARG=${AGENT_ARG} \
-t lostsidewalk/${MODULE_NAME}:${TAG_NAME} \
.
# return to parent dir (composable-rss-app)
cd ..