-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.bash
53 lines (45 loc) · 1.82 KB
/
build.bash
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
#!/bin/bash
# ================================= Edit Here ================================ #
# Change these values to use different versions of ROS or different base images. The rest of the script should be left unchanged.
BASE_IMAGE=osrf/ros
BASE_TAG=humble-desktop-full
IMAGE_NAME=pronto_estimator_framework
IMAGE_TAG=1.5
USERNAME=ros
USER_UID="$(id -u $USER)"
USER_GID="$(id -g $USER)"
WORKSPACE=docker_pronto_ws
# =============================== Help Function ============================== #
helpFunction()
{
echo ""
echo -e "\t-h --help Script used to build the image."
exit 1 # Exit script after printing help
}
# =============================== BUILD ============================== #
# Auxiliary functions
die() { echo "$*" >&2; exit 2; } # complain to STDERR and exit with error
needs_arg() { if [ -z "$OPTARG" ]; then die "No arg for --$OPT option"; fi; }
no_arg() { if [ -n "$OPTARG" ]; then die "No arg allowed for --$OPT option"; fi; }
# Get the script options. This accepts both single dash (e.g. -a) and double dash options (e.g. --all)
while getopts h-: OPT; do
# support long options: https://stackoverflow.com/a/28466267/519360
if [ "$OPT" = "-" ]; then # long option: reformulate OPT and OPTARG
OPT="${OPTARG%%=*}" # extract long option name
OPTARG="${OPTARG#$OPT}" # extract long option argument (may be empty)
OPTARG="${OPTARG#=}" # if long option argument, remove assigning `=`
fi
case "$OPT" in
h | help ) no_arg; helpFunction ;;
esac
done
docker build \
--build-arg BASE_IMAGE=$BASE_IMAGE \
--build-arg BASE_TAG=$BASE_TAG \
--build-arg IMAGE_NAME=$IMAGE_NAME \
--build-arg IMAGE_TAG=$IMAGE_TAG \
--build-arg USERNAME=$USERNAME \
--build-arg USER_UID=$USER_UID \
--build-arg USER_GID=$USER_GID \
--build-arg WORKSPACE=$WORKSPACE \
-t $IMAGE_NAME:$IMAGE_TAG .