forked from ndelitski/rancher-alarms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
env.sh
executable file
·69 lines (57 loc) · 1.21 KB
/
env.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
66
67
68
69
#!/bin/bash
set -e
repo=ndelitski
image=rancher-alarms
version_default=latest
container_name=$image
build() {
local tg=${1:-$version_default}
docker build --pull --rm -t ${image} ./
tag $tg
}
push() {
local version=${1:-$version_default}
tag $version
docker push ${repo}/${image}:${version}
}
tag() {
local tg=$1
docker tag ${image} ${repo}/${image}:${tg}
}
check_state() {
local container_id=$1
local desired_state=$2
docker inspect -f "{{.State.${desired_state}}}" ${container_id}
}
check_exists() {
docker inspect $1 > /dev/null && echo "true" || echo "false"
}
run() {
# if [ "$(check_exists ${container_name})" = "true" ]; then
# if [ "$(check_state ${container_name} Running)" = "true" ]; then
# docker kill ${container_name}
# fi
# docker rm -f ${container_name}
# fi
docker rm -f ${container_name} > /dev/null
docker run \
-it --label io.rancher.container.network=true \
-e CONFIG_FILE=/etc/rancher-alarms/config.json \
-v $(pwd)/config.json:/etc/rancher-alarms/config.json \
--name ${container_name} \
${image}
}
case "$1" in
'build')
build ${@:2}
;;
'run')
run
;;
'tag')
tag ${@:2}
;;
'push')
push ${@:2}
;;
esac