-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker.sh
executable file
·65 lines (52 loc) · 1.06 KB
/
docker.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
65
#!/bin/bash
CMDS=(build push run)
IMAGES=(current fedora ubuntu archlinux)
function print_array {
local -n ary=$1
[[ -n $2 ]] && local IFS="$2"
printf "%s\n" "${ary[*]}"
}
function contains {
local -n ary=$1
local elem="$2"
local size=${#ary[@]}
for (( i=0; $i < $size; i++ )); do
[[ ${ary[$i]} == $elem ]] && return 0
done
return 1
}
function usage {
printf "USAGE: %s (%s) <image>\n" "$0" $(print_array CMDS '|') >&2
printf "where <image> is one of: (%s)\n" $(print_array IMAGES '|') >&2
[[ -n $1 ]] && exit $1
}
contains CMDS "$1" || {
printf "Unrecognized command: %s\n" "$1" >&2
usage 1
}
CMD=$1
shift
contains IMAGES "$1" || {
printf "Unrecognized image: %s\n" "$1" >&2
usage 1
}
IMAGE=$1
shift
[[ -n $1 ]] && usage 1
IMAGE_FULL=usiverify/verify-env:$IMAGE
case $CMD in
build)
DOCKER_BUILDKIT=1 docker build -f Dockerfile-verify-$IMAGE --rm -t $IMAGE_FULL .
;;
push)
docker push $IMAGE_FULL
;;
run)
docker run -it $IMAGE_FULL
;;
## Should not be reached ...
*)
printf "Invalid command: %s\n" $CMD >&2
usage 1
;;
esac