-
Notifications
You must be signed in to change notification settings - Fork 17
/
portal
executable file
·181 lines (150 loc) · 4.45 KB
/
portal
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#!/bin/bash
if [ -z "$COOG_CODE_DIR" ] || [ ! -d "$COOG_CODE_DIR" ] || [ -z "$COOG_DATA_DIR" ]
then
{
echo "Please make sure that these two env vars are set:"
echo " COOG_CODE_DIR: your coog-admin install folder"
echo " COOG_DATA_DIR: the folder where to keep your custom config"
} >&2 && exit 1
fi
_export_conf_docker() {
echo "Export shared env"
export NETWORK_NAME COOG_DB_NAME
export COOG_URL COOG_DB_NAME
if [ ! -z "$CUSTOMER" ]
then
echo $CUSTOMER
export CUSTOMER="-$CUSTOMER"
fi
export JWT_INTERNAL_ENCRYPTION
echo "Export portal envs"
export PORTAL_VERSION
export APP_B2C_VERSION
echo "Export api envs"
export API_VERSION API_WEB_TOKEN API_B2C_VERSION API_B2B_CONFIG_VERSION \
API_MONGO_DB_NAME COOG_DOCUMENT_TOKEN_SECRET API_REFERENTIAL_VERSION \
API_IDENTITY_VERSION
echo "Export gateway envs"
export GATEWAY_VERSION GATEWAY_WHITELIST COOG_PORTAL_URL JWT_ENCRYPTION \
JWT_EXPIRATION GATEWAY_WEB_TOKEN GATEWAY_MONGO_DB_NAME COOG_GATEWAY_URL
if [ -z "$COOG_GATEWAY_BASE_PATH" ]
then
export COOG_GATEWAY_BASE_PATH=""
else
export COOG_GATEWAY_BASE_PATH
fi
if [ -z "$COOG_API_URL" ]
then
export COOG_API_URL="http://${NETWORK_NAME}-web:3000"
else
export COOG_API_URL
fi
if [ -z "$COOG_API_URL_V2" ]
then
export COOG_API_URL_V2="http://${NETWORK_NAME}-api:3000"
else
export COOG_API_URL_V2
fi
if [ -z "$COOG_API_B2C_URL" ]
then
export COOG_API_B2C_URL="http://${NETWORK_NAME}-api-b2c:3000"
else
export COOG_API_B2C_URL
fi
if [ -z "$COOG_API_IDENTITY_MANAGER_URL" ]
then
export COOG_API_IDENTITY_MANAGER_URL="http://${NETWORK_NAME}-api-identity-manager:3000"
else
export COOG_API_IDENTITY_MANAGER_URL
fi
if [ -z "$COOG_API_B2B_CONFIG_URL" ]
then
export COOG_API_B2B_CONFIG_URL="http://${NETWORK_NAME}-api-b2b-config:3000"
else
export COOG_API_B2B_CONFIG_URL
fi
if [ -z "$COOG_API_REFERENTIAL_URL" ]
then
export COOG_API_REFERENTIAL_URL="http://${NETWORK_NAME}-api-referential:3000"
else
export COOG_API_REFERENTIAL_URL
fi
if [ -z "$API_IDENTITY_MONGO_DB_NAME" ]
then
export API_IDENTITY_MONGO_DB_NAME=coog-identity-manager
fi
if [ -z "$API_MONGO_DB_NAME" ]
then
export API_MONGO_DB_NAME=coog-api-v2
fi
if [ -z "$GATEWAY_MONGO_DB_NAME" ]
then
export GATEWAY_MONGO_DB_NAME=coog-gateway
fi
echo "Export gateway authentication activation"
export COOG_MODULE
echo "Export mongo envs"
export MONGO_IMAGE MONGO_USER MONGO_PASSWORD MONGO_PORT
}
_build_conf_docker() {
echo "set version of images"
if [ ! -z "$CUSTOMER" ]
then
echo $CUSTOMER
export CUSTOMER="-$CUSTOMER"
fi
export PORTAL_VERSION="$1"
export APP_B2C_VERSION="$1"
export API_VERSION="$1"
export API_REFERENTIAL_VERSION="$1"
export API_IDENTITY_VERSION="$1"
export API_B2C_VERSION="$1"
export API_B2B_CONFIG_VERSION="$1"
export GATEWAY_VERSION="$1"
export REACT_APP_PROD_API_URL REACT_APP_PORTAL_URL
export MONGO_IMAGE NETWORK_NAME
}
_build() {
_build_conf_docker "$@"
cd "$COOG_CODE_DIR/images/portal" && ./build "$@"
}
_up() {
_export_conf_docker
cd images/portal
docker-compose -p "$NETWORK_NAME-portal" up -d "$@"
}
_restart() {
_export_conf_docker
cd images/portal
docker-compose -p "$NETWORK_NAME-portal" restart "$@"
}
_down() {
_export_conf_docker
cd images/portal
docker-compose -p "$NETWORK_NAME-portal" down "$@"
}
########
# main #
########
usage() {
echo
echo Admin commands
echo
echo " build -> build portal image: <tag> <repo:branch>+"
echo " down -> shut down all container"
echo " down api gateway ... -> shut down relative container"
echo " up -> running all container"
echo " up api gateway ... -> running relative container"
return 0
}
main() {
source "$COOG_CODE_DIR/config"
[ -z "$1" ] && usage && return 0
local cmd; cmd="$1"; shift
[ "$cmd" = "build" ] && { (_build "$@"); return $?; }
[ "$cmd" = "down" ] && { (_down "$@"); return $?; }
[ "$cmd" = "up" ] && { (_up "$@"); return $?; }
[ "$cmd" = "restart" ] && { (_restart "$@"); return $?; }
usage
}
main "$@"