-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path5.execute_single_server_docker.sh
More file actions
206 lines (181 loc) · 5.8 KB
/
5.execute_single_server_docker.sh
File metadata and controls
206 lines (181 loc) · 5.8 KB
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
#!/bin/sh
# Use -w | --wait flag to pause between setup and execution
# Read arguments
for key in "$@"
do
case $key in
-w|--wait)
WAIT="true"
;;
esac
done
# Pause until [ENTER] is pressed
# $1 The text to display while waiting
function pause() {
read -p "$*"
}
# Check if WebLogic server is listening
# $1 Server port to search for
wls_is_listening() {
CHECK=$(curl -I localhost:${1} 2>/dev/null | head -n 1 | cut -d$' ' -f2)
if [ -z "$CHECK" ]; then
return 1
else
return 0
fi
}
# Wait for host:port to become active
# $1 Port to check
# $2 Waiting timeout in seconds
wait_for_weblogic() {
START_TIME=`date +%s`
TIMEOUT='false'
while [ "${TIMEOUT}" = 'false' ] && ! wls_is_listening "${1}"; do
PASSED_TIME=$((`date +%s` - ${START_TIME}))
if [ "${PASSED_TIME}" -gt "${2}" ]; then
echo 'Port check timeout after '${PASSED_TIME}' seconds'
TIMEOUT='true'
else
if [ "$((PASSED_TIME%10))" -eq '0' ]; then
printf "${PASSED_TIME}"
else
printf '.'
fi
sleep 1;
fi
done
if [ "${TIMEOUT}" = 'false' ]; then
return 0
else
return 1
fi
}
ORACLE_HOME="${ORACLE_HOME:=/opt/wls/Oracle_Home}"
WL_HOME="${WL_HOME:=$ORACLE_HOME/wlserver}"
echo ''
echo ' ########################################################## '
echo ' ----------- Running with following environment------------ '
echo ' ########################################################## '
echo ''
echo ''
echo 'ORACLE_HOME='$ORACLE_HOME
echo 'WL_HOME='$WL_HOME
echo 'PROXY_URL='$PROXY_URL
echo 'JDK_ARCHIVE='$JDK_ARCHIVE
echo 'WLS_ARCHIVE='$WLS_ARCHIVE
echo 'DOCKER_VM='$DOCKER_VM
echo ''
if [ -z "$JDK_ARCHIVE" ];
then
echo 'Please provide JDK_ARCHIVE property with full path to a JDK install archive for Linux x64'
exit
fi
if [ -z "$WLS_ARCHIVE" ];
then
echo 'Please provide WLS_ARCHIVE property with full path to a WebLogic installation jar'
exit
fi
if [ -n "$WAIT" ];
then
echo 'Will wait for confirmation after setup'
fi
WLST=$ORACLE_HOME/oracle_common/common/bin/wlst.sh
cd build/
echo ''
echo ' ########################################################## '
echo ' ------------------ Building project ------------------ '
echo ' ########################################################## '
echo ''
bash ./build.sh
echo ''
echo ' ########################################################## '
echo ' ----------------- Performing cleanup ----------------- '
echo ' ########################################################## '
echo ''
docker rm AdminServer
docker rmi weblogic
echo ''
echo ' ########################################################## '
echo ' ---------------- Building docker image --------------- '
echo ' ########################################################## '
echo ''
mkdir -p /tmp/docker
cp $JDK_ARCHIVE /tmp/docker
cp $WLS_ARCHIVE /tmp/docker
cp docker/Dockerfile /tmp/docker
cp create-domain.py /tmp/docker
docker build \
-f /tmp/docker/Dockerfile \
--build-arg JDK_ARCHIVE=$(basename $JDK_ARCHIVE) \
--build-arg WLS_ARCHIVE=$(basename $WLS_ARCHIVE) \
--build-arg PROXY_URL=$PROXY_URL \
-t weblogic \
/tmp/docker
rm -r /tmp/docker
if [ -n "$DOCKER_VM" ];
then
echo ''
echo ' ########################################################## '
echo ' ---------------- Creating port forward --------------- '
echo ' ########################################################## '
echo ''
VBoxManage controlvm $DOCKER_VM natpf1 "admin,tcp,127.0.0.1,7001,,7001"
echo 'Created port forward from docker VM '$DOCKER_VM' port 7001 to local port 7001'
fi
echo ''
echo ' ########################################################## '
echo ' ---------------- Starting docker image --------------- '
echo ' ########################################################## '
echo ''
docker run -d \
-p 7001:7001 \
--name AdminServer \
weblogic
wait_for_weblogic 7001 300
echo ''
echo ''
echo ' ########################################################## '
echo ' ---------------- Creating partitions ----------------- '
echo ' ########################################################## '
echo ''
$WLST create-partitions.py
echo ''
echo ' ########################################################## '
echo ' ---------------- Creating data source ---------------- '
echo ' ########################################################## '
echo ''
$WLST create-datasources.py
echo ''
echo ' ########################################################## '
echo ' ---------------- Deploying application ---------------- '
echo ' ########################################################## '
echo ''
$WLST deployToDocker.py
if [ -n "$WAIT" ]
then
pause 'Press [ENTER] to continue'
fi
echo ''
echo ' ########################################################## '
echo ' ---------------- Sending test request ----------------- '
echo ' ########################################################## '
echo ''
curl http://localhost:7001/customer-service/CustomerService-1.0-SNAPSHOT/resources/customers
echo ''
echo ' ########################################################## '
echo ' --------------- Stopping docker image ---------------- '
echo ' ########################################################## '
echo ''
docker stop AdminServer
if [ -n "$DOCKER_VM" ];
then
echo ''
echo ' ########################################################## '
echo ' ---------------- Removing port forward --------------- '
echo ' ########################################################## '
echo ''
VBoxManage controlvm $DOCKER_VM natpf1 delete "admin"
echo 'Removed port forward from docker VM '$DOCKER_VM' port 7001 to local port 7001'
echo ''
fi
cd ..