forked from HonuRobotics/dockwater
-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.bash
executable file
·86 lines (78 loc) · 3.15 KB
/
run.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/env bash
#
# Copyright (C) 2018 Open Source Robotics Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Runs a docker container with the image created by build.bash
# Requires:
# docker
# nvidia-docker
# an X server
# rocker
# Recommended:
# A joystick mounted to /dev/input/js0 or /dev/input/js1
############################################################
# Help #
############################################################
Help()
{
# Display Help
echo "Runs a docker container with the image created by build.bash."
echo
echo "Syntax: scriptTemplate [-c|i|r|s|t|h]"
echo "options:"
echo "c Add cuda library support."
echo "i With internal graphics card (without nvidia)"
echo "r With internal graphics card (without nvidia) and with RDP. default user is docker"
echo "s Create an image with novnc for use with cloudsim."
echo "t Create a test image for use with CI pipelines."
echo "x Create base image for the VRX competition server."
echo "h Print this help message and exit."
echo
}
JOY=/dev/input/js0
CUDA=""
ROCKER_ARGS="--devices /dev/dri $JOY --dev-helpers --nvidia --x11 --git --volume $(echo ~):/docker/HOST"
while getopts ":cstxhir" option; do
case $option in
c) # enable cuda library support
CUDA="--cuda";;
i) # With internal graphics card (without nvidia)
ROCKER_ARGS="--devices /dev/dri $JOY --x11 --git --volume $(echo ~):/docker/HOST";;
r) # With internal graphics card (without nvidia) and with RDP default user is docker
# shellcheck disable=SC2116
ROCKER_ARGS="--devices /dev/dri $JOY --x11 --git --port 3389:3389 --volume $(echo ~):/home/docker/HOST";;
s) # Build cloudsim image
ROCKER_ARGS="--nvidia --novnc --turbovnc --user --user-override-name=developer";;
t) # Build test image for Continuous Integration
echo "Building CI image"
ROCKER_ARGS="--dev-helpers --nvidia";;
x) # Build VRX Competition base image
echo "Building VRX Competition server base image"
ROCKER_ARGS="--dev-helpers --devices $JOY --nvidia --x11 --user --user-override-name=developer";;
h) # print this help message and exit
Help
exit;;
\?) # handle unrecognized options
echo "Invalid option: -$OPTARG" >&2
exit 1;;
esac
done
IMG_NAME=${@:$OPTIND:1}
# Replace `:` with `_` to comply with docker container naming
# And append `_runtime`
CONTAINER_NAME="$(tr ':' '_' <<< "$IMG_NAME")_runtime"
ROCKER_ARGS="${ROCKER_ARGS} --name $CONTAINER_NAME"
echo "Using image <$IMG_NAME> to start container <$CONTAINER_NAME>"
rocker ${CUDA} ${ROCKER_ARGS} $IMG_NAME