-
Notifications
You must be signed in to change notification settings - Fork 1
/
run_docker_compose.sh
executable file
·49 lines (43 loc) · 1.22 KB
/
run_docker_compose.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
#!/bin/bash
# start aliases for pushd/popd so they don't echo to console
pushd () {
command pushd "$@" > /dev/null
}
popd () {
command popd "$@" > /dev/null
}
# end pushd/popd aliases
# By default, we do not want to mock the RVR interface or build the container image
mock_rvr_val="false"
shouldbuild=false
ros_domain_id="0"
# Start process option flags if present
while getopts "bmr:" flag
do
case "${flag}" in
b)
echo "Running docker compose with optional build flag"
shouldbuild=true
;;
m)
echo "Mocking the RVR interface"
mock_rvr_val="true"
;;
r)
echo "Setting ROS domain ID to ${OPTARG}"
ros_domain_id="${OPTARG}"
;;
esac
done
# End process option flags
# Get the root directory for the git repo
reporoot=$(git rev-parse --show-toplevel)
# start docker compose, should run from the repo root directory, then return to the pwd on exit
pushd $reporoot
if $shouldbuild; then
trap "MOCK_RVR=$mock_rvr_val ROS_DOMAIN_ID=$ros_domain_id docker compose up --build" EXIT
else
trap "MOCK_RVR=$mock_rvr_val ROS_DOMAIN_ID=$ros_domain_id docker compose up" EXIT
fi
popd
# end docker compose