-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathcreate_docker_image
executable file
·129 lines (116 loc) · 3.5 KB
/
create_docker_image
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/bin/bash
USAGE="""
This script assumes a docker registry is running on your server.
Usage: ./create_docker_image -c CUSTOMER -v VERSION -a COOG ADMIN PATH -i IMAGE TYPE
-c --customer
The customer you release version for.
-v --version
The tag version you release.
-a --admin
The path to coog-admin folder
-i --image
Image type 'coog' or 'web'
"""
_generate_customer_image() {
COOG_CODE_DIR=$PATH_TO_COOG_ADMIN \
COOG_DATA_DIR=$PATH_TO_COOG_ADMIN/data \
$PATH_TO_COOG_ADMIN/coog \
build coopengo/coog-$1:$2 \
customers:$1-coog-$2 \
coog:coog-$2 \
trytond:coog-$2 \
trytond-modules:coog-$2 \
coog-bench:coog-$2 \
sao:coog-$2
docker push "coopengo/coog-$1:$2"
}
_generate_coog_image() {
COOG_CODE_DIR=$PATH_TO_COOG_ADMIN \
COOG_DATA_DIR=$PATH_TO_COOG_ADMIN/data \
$PATH_TO_COOG_ADMIN/coog \
build coopengo/coog:$1 \
coog:coog-$1 \
trytond:coog-$1 \
trytond-modules:coog-$1 \
coog-bench:coog-$1 \
sao:coog-$1
docker push "coopengo/coog:$VERSION"
}
_generate_web_image() {
COOG_CODE_DIR=$PATH_TO_COOG_ADMIN \
COOG_DATA_DIR=$PATH_TO_COOG_ADMIN/data \
$PATH_TO_COOG_ADMIN/web \
build coopengo/web:$1 \
coog-api:coog-$1 \
coog-app:coog-$1
docker push "coopengo/web:$1"
}
_generate_unoconv_image() {
COOG_CODE_DIR=$PATH_TO_COOG_ADMIN \
COOG_DATA_DIR=$PATH_TO_COOG_ADMIN/data \
$PATH_TO_COOG_ADMIN/unoconv \
build coopengo/unoconv:$1
docker push "coopengo/unoconv:$1"
}
_generate_customer_web_image() {
COOG_CODE_DIR=$PATH_TO_COOG_ADMIN \
COOG_DATA_DIR=$PATH_TO_COOG_ADMIN/data \
$PATH_TO_COOG_ADMIN/web \
build coopengo/web-$1:$2 \
coog-api:coog-$2 \
coog-app:coog-$2
docker push "coopengo/web-$1:$2"
}
main(){
if [ "$IMAGE" == "web" ]; then
if [ "$CUSTOMER" == "coog" ]; then
_generate_web_image $VERSION
else
_generate_customer_web_image $CUSTOMER $VERSION
fi
elif [ "$IMAGE" == "coog" ]; then
if [ "$CUSTOMER" == "coog" ]; then
_generate_coog_image $VERSION
else
_generate_customer_image $CUSTOMER $VERSION
fi
elif [ "$IMAGE" == "unoconv" ]; then
if [ "$CUSTOMER" == "coog" ]; then
_generate_unoconv_image $VERSION
fi
fi
}
# Script begins here
[ $# -lt 2 ] && echo "$USAGE" && exit 1
while [[ $# -gt 1 ]]; do
arg="$1"
value="$2"
case $arg in
-c|--customer)
CUSTOMER="$value"
shift
;;
-v|--version)
VERSION="$value"
shift
;;
-a|--admin)
PATH_TO_COOG_ADMIN="$value"
shift
;;
-i|--image)
IMAGE="$value"
shift
;;
*)
echo "Invalid argument $arg."
return 1
;;
esac
shift
done
[ -z "$CUSTOMER" ] && echo "Missing required parameter.$USAGE" && exit 1
[ -z "$VERSION" ] && echo "Missing required parameter.$USAGE" && exit 1
[ -z "$PATH_TO_COOG_ADMIN" ] && echo "Missing required parameter.$USAGE" && exit 1
[ -z "$IMAGE" ] && echo "Missing required parameter.$USAGE" && exit 1
main "$@"