Skip to content

Commit 91d1d72

Browse files
committed
Customize username/password used in building the docker image
Signed-off-by: doxiao <[email protected]>
1 parent 5c9a671 commit 91d1d72

File tree

3 files changed

+31
-12
lines changed

3 files changed

+31
-12
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ Make a copy of the `create-domain-inputs.yaml` file, and run the create script,
1616

1717
```
1818
./create-domain.sh \
19+
-u <username> \
20+
-p <password> \
1921
-i create-domain-inputs.yaml \
2022
-o /path/to/output-directory
2123
```
@@ -24,6 +26,8 @@ The script will perform the following steps:
2426

2527
* Create a directory for the generated properties and Kubernetes YAML files for this domain if it does not already exist. The pathname is `/path/to/weblogic-operator-output-directory/weblogic-domains/<domainUID>`. Note that the script fails if the directory is not empty when the `create-domain.sh` script is executed.
2628
* Create a proerties file, `domain.properties`, in the directory that is created above. This properties file will be used to create a sample WebLogic Server domain.
29+
* Clone the weblogic docker-images project via the `git clone https://github.com/oracle/docker-images.git` into the current directory.
30+
* Replace the built-in username and password in the properties/docker_build/domain_security.properties file with the `username` and `password` that are supplied in the command line via the `-u` and `-p` options. These credentials need to match the WebLogic domain admin credentials in the secret that is specified via `weblogicCredentialsSecretName` property in the `create-domain-inputs.yaml` file.
2731
* Build Docker image based on Docker sample [Example Image with a WebLogic Server Domain](https://github.com/oracle/docker-images/tree/master/OracleWebLogic/samples/12213-domain-home-in-image). It will create a sample WebLogic Server domain into the Docker image. You can also run the Docker sample [Example Image with a WebLogic Server Domain](https://github.com/oracle/docker-images/tree/master/OracleWebLogic/samples/12213-domain-home-in-image) manually with the generated `domain.properties` to create domain home image. Note: Oracle recommends keeping the domain home image private in the local repository.
2832
* Create a Kubernetes domain YAML file, `domain.yaml`, in the directory that is created above. This YAML file can be used to create the Kubernetes resource using the `kubectl create -f` or `kubectl apply -f` command.
2933

@@ -33,10 +37,12 @@ The usage of the create script is as follows:
3337

3438
```
3539
$ sh create-domain.sh -h
36-
usage: create-domain.sh -o dir -i file [-e] [-h]
40+
usage: create-domain.sh -o dir -i file -u username -p password [-e] [-h]
3741
-i Parameter inputs file, must be specified.
38-
-o Output directory for the generated properties and YAML files, must be specified.
39-
-e Also create the resources in the generated YAML file, optional.
42+
-o Ouput directory for the generated properties and YAML files, must be specified.
43+
-u Username used in building the Docker image for WebLogic domain in image.
44+
-p Password used in building the Docker image for WebLogic domain in image.
45+
-e Also create the resources in the generated YAML files, optional.
4046
-h Help
4147
4248
```

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

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

2222
function usage {
23-
echo usage: ${script} -o dir -i file [-e] [-h]
23+
echo usage: ${script} -o dir -i file -u username -p password [-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."
26+
echo " -u Username used in building the Docker image for WebLogic domain in image."
27+
echo " -p Password used in building the Docker image for WebLogic domain in image."
2628
echo " -e Also create the resources in the generated YAML files, optional."
2729
echo " -h Help"
2830
exit $1
@@ -32,14 +34,18 @@ function usage {
3234
# Parse the command line options
3335
#
3436
executeIt=false
35-
while getopts "evhi:o:" opt; do
37+
while getopts "evhi:o:u:p:" opt; do
3638
case $opt in
3739
i) valuesInputFile="${OPTARG}"
3840
;;
3941
o) outputDir="${OPTARG}"
4042
;;
4143
e) executeIt=true
4244
;;
45+
u) username="${OPTARG}"
46+
;;
47+
p) password="${OPTARG}"
48+
;;
4349
h) usage 0
4450
;;
4551
*) usage 1
@@ -52,6 +58,16 @@ if [ -z ${valuesInputFile} ]; then
5258
missingRequiredOption="true"
5359
fi
5460

61+
if [ -z ${username} ]; then
62+
echo "${script}: -u must be specified."
63+
missingRequiredOption="true"
64+
fi
65+
66+
if [ -z ${password} ]; then
67+
echo "${script}: -p must be specified."
68+
missingRequiredOption="true"
69+
fi
70+
5571
if [ -z ${outputDir} ]; then
5672
echo "${script}: -o must be specified."
5773
missingRequiredOption="true"
@@ -349,6 +365,10 @@ function createDomainHome {
349365
cp ${domainPropertiesOutput} ./docker-images/OracleWebLogic/samples/12213-domain-home-in-image/properties/docker_build
350366

351367
cd docker-images/OracleWebLogic/samples/12213-domain-home-in-image
368+
369+
sed -i -e "s|myuser|${username}|g" properties/docker_build/domain_security.properties
370+
sed -i -e "s|mypassword1|${password}|g" properties/docker_build/domain_security.properties
371+
352372
./build.sh
353373

354374
if [ "$?" != "0" ]; then

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,6 @@ spec:
4949
value: "%JAVA_OPTIONS%"
5050
- name: USER_MEM_ARGS
5151
value: "-Xms64m -Xmx256m "
52-
volumes:
53-
- name: runtime-properties
54-
hostPath:
55-
path: "%RUNTIME_PROPERTIES%"
56-
volumeMounts:
57-
- mountPath: "/u01/oracle/properties"
58-
name: runtime-properties
5952
# adminServer is used to configure the desired behavior for starting the administration server.
6053
adminServer:
6154
# serverStartState legal values are "RUNNING" or "ADMIN"

0 commit comments

Comments
 (0)