Skip to content

Commit 3659482

Browse files
doxiaomarkxnelson
authored andcommitted
Add an option to not alway clone the docker images project plus bug-fixing (#656)
* Add an option to save previous cloned project dir and fix a problem with image setting Signed-off-by: doxiao <[email protected]> * Update README plus minor modification Signed-off-by: doxiao <[email protected]> * Change -s to -k Signed-off-by: doxiao <[email protected]>
1 parent c1a8277 commit 3659482

File tree

3 files changed

+34
-13
lines changed

3 files changed

+34
-13
lines changed

kubernetes/samples/scripts/create-weblogic-domain/domain-home-in-image/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,14 @@ The usage of the create script is as follows:
3737

3838
```
3939
$ sh create-domain.sh -h
40-
usage: create-domain.sh -o dir -i file -u username -p password [-e] [-h]
40+
usage: create-domain.sh -o dir -i file -u username -p password [-s] [-e] [-h]
4141
-i Parameter inputs file, must be specified.
4242
-o Ouput directory for the generated properties and YAML files, must be specified.
4343
-u Username used in building the Docker image for WebLogic domain in image.
4444
-p Password used in building the Docker image for WebLogic domain in image.
4545
-e Also create the resources in the generated YAML files, optional.
46+
-k Keep what has been previously cloned from https://github.com/oracle/docker-images.git, optional.
47+
If not specified, this script will always remove existing project and clone again.
4648
-h Help
4749
4850
```

kubernetes/samples/scripts/create-weblogic-domain/domain-home-in-image/create-domain.sh

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ source ${scriptDir}/../../common/utility.sh
2020
source ${scriptDir}/../../common/validate.sh
2121

2222
function usage {
23-
echo usage: ${script} -o dir -i file -u username -p password [-e] [-h]
23+
echo usage: ${script} -o dir -i file -u username -p password [-k] [-e] [-h]
2424
echo " -i Parameter inputs file, must be specified."
2525
echo " -o Ouput directory for the generated properties and YAML files, must be specified."
2626
echo " -u Username used in building the Docker image for WebLogic domain in image."
2727
echo " -p Password used in building the Docker image for WebLogic domain in image."
2828
echo " -e Also create the resources in the generated YAML files, optional."
29+
echo " -k Keep what has been previously from cloned https://github.com/oracle/docker-images.git, optional. "
30+
echo " If not specified, this script will always remove existing project directory and clone again."
2931
echo " -h Help"
3032
exit $1
3133
}
@@ -34,7 +36,8 @@ function usage {
3436
# Parse the command line options
3537
#
3638
executeIt=false
37-
while getopts "evhi:o:u:p:" opt; do
39+
cloneIt=true
40+
while getopts "evhki:o:u:p:" opt; do
3841
case $opt in
3942
i) valuesInputFile="${OPTARG}"
4043
;;
@@ -46,6 +49,8 @@ while getopts "evhi:o:u:p:" opt; do
4649
;;
4750
p) password="${OPTARG}"
4851
;;
52+
k) cloneIt=false;
53+
;;
4954
h) usage 0
5055
;;
5156
*) usage 1
@@ -138,14 +143,16 @@ function initialize {
138143

139144
initOutputDir
140145

141-
getDockerSample
146+
if [ "${cloneIt}" = true ]; then
147+
getDockerSample
148+
fi
142149
}
143150

144151
#
145152
# Function to get the dependency docker sample
146153
#
147154
function getDockerSample {
148-
rm -rf {scriptDir}/docker-images
155+
rm -rf ${scriptDir}/docker-images
149156
git clone https://github.com/oracle/docker-images.git
150157
}
151158

@@ -232,12 +239,21 @@ function createFiles {
232239
# Function to build docker image and create WebLogic domain home
233240
#
234241
function createDomainHome {
235-
cp ${domainPropertiesOutput} ./docker-images/OracleWebLogic/samples/12213-domain-home-in-image/properties/docker_build
236-
237242
if [ -z $imagePath ]; then
238243
imagePath="12213-domain-home-in-image-wdt"
239244
fi
240245

246+
cp ${domainPropertiesOutput} ./docker-images/OracleWebLogic/samples/${imagePath}/properties/docker_build
247+
248+
imageName="12213-domain-home-in-image:latest"
249+
# use the existence of build-archive.sh file to determine if we need to download WDT
250+
if [ -f "./docker-images/OracleWebLogic/samples/${imagePath}/build-archive.sh" ]; then
251+
imageName="12213-domain-wdt:latest"
252+
fi
253+
254+
# now we know which image to use, update the domain yaml file
255+
sed -i -e "s|%IMAGE_NAME%|${imageName}|g" ${dcrOutput}
256+
241257
cd docker-images/OracleWebLogic/samples/${imagePath}
242258

243259
# 12213-domain-home-in-image use one properties file for the credentials
@@ -248,11 +264,13 @@ function createDomainHome {
248264
if [ ! -f $usernameFile ]; then
249265
usernameFile="properties/docker-build/adminuser.properties"
250266
passwordFile="properties/docker-build/adminpass.properties"
267+
sed -i -e "s|weblogic|${username}|g" $usernameFile
268+
sed -i -e "s|welcome1|${password}|g" $passwordFile
269+
else
270+
sed -i -e "s|myuser|${username}|g" $usernameFile
271+
sed -i -e "s|mypassword1|${password}|g" $passwordFile
251272
fi
252273

253-
sed -i -e "s|myuser|${username}|g" $usernameFile
254-
sed -i -e "s|mypassword1|${password}|g" $passwordFile
255-
256274
# use the existence of build-archive.sh file to determine if we need to download WDT
257275
if [ -f "build-archive.sh" ]; then
258276
sh ./build-archive.sh

kubernetes/samples/scripts/create-weblogic-domain/domain-home-in-image/domain-template.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ spec:
1717
# If the domain home is in the image
1818
domainHomeInImage: true
1919
# The Operator currently does not support other images
20-
image: "12213-domain-home-in-image:latest"
20+
image: %IMAGE_NAME%
2121
# imagePullPolicy defaults to "Never"
2222
imagePullPolicy: "Never"
2323
# Identify which Secret contains the WebLogic Admin credentials (note that there is an example of
@@ -26,9 +26,9 @@ spec:
2626
name: %WEBLOGIC_CREDENTIALS_SECRET_NAME%
2727
# Whether to include the server out file into the pod's stdout, default is true
2828
includeServerOutInPodLog: %INCLUDE_SERVER_OUT_IN_POD_LOG%
29-
# serverStartPolicy legal values are "NEVER", "ALWAYS", "IF_NEEDED", or "ADMIN_ONLY"
29+
# serverStartPolicy legal values are "NEVER", "IF_NEEDED", or "ADMIN_ONLY"
3030
# This determines which WebLogic Servers the Operator will start up when it discovers this Domain
31-
# - "ALWAYS" will start up all defined servers
31+
# - "NEVER" will not start any servers in the domain
3232
# - "ADMIN_ONLY" will start up only the administration server (no managed servers will be started)
3333
# - "IF_NEEDED" will start all non-clustered servers, including the administration server and clustered servers up to the replica count
3434
serverStartPolicy: "%SERVER_START_POLICY%"
@@ -58,3 +58,4 @@ spec:
5858
replicas: %INITIAL_MANAGED_SERVER_REPLICAS%
5959
# The number of managed servers to start from clusters not listed in clusters
6060
# replicas: 1
61+

0 commit comments

Comments
 (0)