-
Notifications
You must be signed in to change notification settings - Fork 65
/
run.sh
executable file
·36 lines (32 loc) · 891 Bytes
/
run.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
#!/bin/bash
# defaults
INPUT_DIR="/data/"
OUTPUT_DIR="/data/output"
IMAGE_TAG="udacity-reader"
RUN_SCRIPT="/bin/bash"
INTERACTIVE="-it"
usage() { echo "Usage: $0 [-i input_dir] [-o output_dir] [-t image_tag]" 1>&2; exit 1; }
while getopts ":i:o:t:r:h" opt; do
case $opt in
i) INPUT_DIR=$OPTARG ;;
o) OUTPUT_DIR=$OPTARG ;;
t) IMAGE_TAG=$OPTARG ;;
r) RUN_SCRIPT=$OPTARG; INTERACTIVE='' ;;
h) usage ;;
\?)
echo "Invalid option: -$OPTARG" >&2
usage
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
shift "$((OPTIND - 1))"
echo "Running '$RUN_SCRIPT' with input dir '$INPUT_DIR', output dir '$OUTPUT_DIR', docker image '$IMAGE_TAG'..."
docker run --rm $INTERACTIVE\
--volume="/$(pwd)/script:/script"\
--volume="$INPUT_DIR:/data"\
--volume="$OUTPUT_DIR:/output"\
$IMAGE_TAG $RUN_SCRIPT "$@"