-
Notifications
You must be signed in to change notification settings - Fork 19
/
build
executable file
·86 lines (73 loc) · 1.76 KB
/
build
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
#!/bin/bash
VALID_CMDS=(make push manifest)
GIT_VER=$(git rev-list -1 HEAD)
ARCH=$(uname -m)
IMAGE_NAME=sriov-plugin
ARCH_IMAGE=rdma/$IMAGE_NAME:$ARCH
LATEST_IMAGE=rdma/$IMAGE_NAME:latest
input_cmd=make
function usage_help()
{
echo "./build [COMMAND]"
echo "Examples:"
echo "./build make To build the image"
echo "./build push To push image to hub.docker.com"
echo "./build manifest Modify and push manifest to hub.docker.com"
}
function check_for_help()
{
case $1 in
"-h" | "--help")
usage_help
exit 0
;;
esac
}
function validate_input_cmd()
{
valid_cmd="make"
in_cmd=$1
for n in "${VALID_CMDS[@]}"; do
if [ "$in_cmd" = "$n" ]; then
valid_cmd=$in_cmd
fi
done
if [ -z $valid_cmd ]; then
echo "Given command $in_cmd is invalid"
usage_help
exit 1
fi
}
function execute_cmd()
{
case "$input_cmd" in
"make")
echo "Building image: $ARCH_IMAGE"
docker build . --force-rm -t $ARCH_IMAGE
;;
"push")
echo "Pushing images"
docker push $ARCH_IMAGE
;;
"manifest")
echo "Pushing images"
docker manifest create rdma/$IMAGE_NAME rdma/$IMAGE_NAME:x86_64 rdma/$IMAGE_NAME:ppc64le
docker manifest create --amend rdma/$IMAGE_NAME rdma/$IMAGE_NAME:x86_64 rdma/$IMAGE_NAME:ppc64le
docker manifest annotate rdma/$IMAGE_NAME rdma/$IMAGE_NAME:x86_64 --os linux --arch amd64
docker manifest annotate rdma/$IMAGE_NAME rdma/$IMAGE_NAME:ppc64le --os linux --arch ppc64le
docker manifest push rdma/$IMAGE_NAME -p
;;
"start")
echo "starting plugin"
docker run -v /run/docker/plugins:/run/docker/plugins --net=host --privileged rdma/sriov-plugin:$ARCH
;;
esac
}
check_for_help $1
validate_input_cmd $1
if [ $# -lt 1 ]; then
input_cmd=make
else
input_cmd=$1
fi
execute_cmd