Skip to content

Commit df3712b

Browse files
authored
Merge pull request #135 from oracle/issue#134-access-property-file-from-mounted-volume
Issue#134 access property file from mounted volume
2 parents 05944bb + 280dce5 commit df3712b

File tree

7 files changed

+98
-23
lines changed

7 files changed

+98
-23
lines changed

samples/docker-domain/Dockerfile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@
1919
# $ sudo docker build \
2020
# --build-arg WDT_MODEL=simple-topology.yaml \
2121
# --build-arg WDT_ARCHIVE=archive.zip \
22+
# --force-rm=true \
2223
# -t 12213-domain-wdt .
2324
#
2425
# Pull base image
2526
# ---------------
26-
FROM store/oracle/weblogic:12.2.1.3
27+
# FROM store/oracle/weblogic:12.2.1.3
28+
FROM oracle/weblogic:12.2.1.3-developer
2729

2830
# Maintainer
2931
# ----------
@@ -56,7 +58,11 @@ COPY container-scripts/* /u01/oracle/
5658
COPY weblogic-deploy.zip /u01
5759
COPY ${WDT_MODEL} ${ARCHIVE_FILE} /u01/
5860

59-
#Create directory where domain will be written to
61+
# this file contains credentials.
62+
# be sure to build with --force-rm to eliminate this container layer
63+
COPY properties /u01/oracle
64+
65+
# Create directory where domain will be written to
6066
USER root
6167
RUN chmod +xw /u01/oracle/*.sh && \
6268
chmod +xw /u01/oracle/*.py && \
@@ -78,7 +84,8 @@ RUN chmod +xw /u01/oracle/*.sh && \
7884
-variable_file /u01/oracle/domain.properties \
7985
$MODEL_OPT \
8086
$ARCHIVE_OPT && \
81-
chown -R oracle:oracle $PRE_DOMAIN_HOME
87+
chown -R oracle:oracle $PRE_DOMAIN_HOME && \
88+
rm /u01/oracle/domain.properties
8289

8390
VOLUME $PRE_DOMAIN_HOME
8491
# Expose Node Manager default port, and also default for admin and managed server

samples/docker-domain/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ When the WDT discoverDomain tool is used on an existing domain, a ZIP archive is
1818

1919
### How to Build and Run
2020

21-
**NOTE:** The image is based on a WebLogic image in the Docker store: store/oracle/weblogic:12.2.1.3 . Download this image to your local repository before building the image.
21+
**NOTE:** The image is based on a WebLogic image in the docker-images project: oracle/weblogic:12.2.1.3-developer . Build that image to your local repository before building this sample.
2222

2323
The WebLogic Deploy Tool installer is required to build this image. Add weblogic-deploy.zip to the sample directory.
2424

@@ -33,21 +33,22 @@ To build this sample, run:
3333
$ docker build \
3434
--build-arg WDT_MODEL=simple-topology.yaml \
3535
--build-arg WDT_ARCHIVE=archive.zip \
36+
--force-rm=true \
3637
-t 12213-domain-wdt .
3738

3839
This will use the model file and archive in the sample directory.
3940

4041
To start the containerized Administration Server, run:
4142

42-
$ docker run -d --name wlsadmin --hostname wlsadmin -p 7001:7001 --env-file ./container-scripts/domain.properties 12213-domain-wdt
43+
$ docker run -d --name wlsadmin --hostname wlsadmin -p 7001:7001 -v <sample-directory>/properties:/u01/oracle/properties 12213-domain-wdt
4344

4445
To start a containerized Managed Server (ms-1) to self-register with the Administration Server above, run:
4546

46-
$ docker run -d --name ms-1 --link wlsadmin:wlsadmin -p 9001:9001 --env-file ./container-scripts/domain.properties -e ADMIN_PASSWORD=<admin_password> -e MS_NAME=ms-1 12213-domain-wdt startManagedServer.sh
47+
$ docker run -d --name ms-1 --link wlsadmin:wlsadmin -p 9001:9001 -v <sample-directory>/properties:/u01/oracle/properties -e MS_NAME=ms-1 12213-domain-wdt startManagedServer.sh
4748

4849
To start an additional Managed Server (in this example ms-2), run:
4950

50-
$ docker run -d --name ms-2 --link wlsadmin:wlsadmin -p 9002:9001 --env-file ./container-scripts/domain.properties -e ADMIN_PASSWORD=<admin_password> -e MS_NAME=ms-2 12213-domain-wdt startManagedServer.sh
51+
$ docker run -d --name ms-2 --link wlsadmin:wlsadmin -p 9002:9001 -v <sample-directory>/properties:/u01/oracle/properties -e MS_NAME=ms-2 12213-domain-wdt startManagedServer.sh
5152

5253
The above scenario from this sample will give you a WebLogic domain with a dynamic cluster set up on a single host environment.
5354

samples/docker-domain/container-scripts/domain.properties

Lines changed: 0 additions & 4 deletions
This file was deleted.

samples/docker-domain/container-scripts/startManagedServer.sh

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,48 @@
66
#
77
# Start the Domain.
88

9+
PROPERTIES_FILE=/u01/oracle/properties/domain.properties
10+
if [ ! -e "$PROPERTIES_FILE" ]; then
11+
echo "A properties file with variable definitions needs to be supplied."
12+
exit
13+
fi
14+
15+
DOMAIN_NAME=`awk '{print $1}' $PROPERTIES_FILE | grep ^DOMAIN_NAME= | cut -d "=" -f2`
16+
if [ -z "$DOMAIN_NAME" ]; then
17+
echo "The domain name is blank. The domain name must be set in the properties file."
18+
exit
19+
fi
20+
21+
USER=`awk '{print $1}' $PROPERTIES_FILE | grep ^username= | cut -d "=" -f2`
22+
if [ -z "$USER" ]; then
23+
echo "The admin username is blank. The admin username must be set in the properties file."
24+
exit
25+
fi
26+
27+
PASS=`awk '{print $1}' $PROPERTIES_FILE | grep ^password= | cut -d "=" -f2`
28+
if [ -z "$PASS" ]; then
29+
echo "The admin password is blank. The admin password must be set in the properties file."
30+
exit
31+
fi
32+
33+
ADMIN_HOST=`awk '{print $1}' $PROPERTIES_FILE | grep ^ADMIN_HOST= | cut -d "=" -f2`
34+
if [ -z "$ADMIN_HOST" ]; then
35+
echo "The admin host is blank. The admin host must be set in the properties file."
36+
exit
37+
fi
38+
39+
ADMIN_PORT=`awk '{print $1}' $PROPERTIES_FILE | grep ^ADMIN_PORT= | cut -d "=" -f2`
40+
if [ -z "$ADMIN_PORT" ]; then
41+
echo "The admin port is blank. The admin port must be set in the properties file."
42+
exit
43+
fi
44+
945
#Define DOMAIN_HOME
1046
export DOMAIN_HOME=/u01/oracle/user_projects/domains/$DOMAIN_NAME
1147

1248
mkdir -p $DOMAIN_HOME/servers/$MS_NAME/security
13-
echo username=$ADMIN_USER > $DOMAIN_HOME/servers/$MS_NAME/security/boot.properties
14-
echo password=$ADMIN_PASSWORD >> $DOMAIN_HOME/servers/$MS_NAME/security/boot.properties
49+
echo username=$USER > $DOMAIN_HOME/servers/$MS_NAME/security/boot.properties
50+
echo password=$PASS >> $DOMAIN_HOME/servers/$MS_NAME/security/boot.properties
1551

1652
# Start Managed Server and tail the logs
1753
${DOMAIN_HOME}/bin/startManagedWebLogic.sh $MS_NAME http://$ADMIN_HOST:$ADMIN_PORT

samples/docker-domain/container-scripts/startWLSDomain.sh

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,37 @@
66
#
77
# Start the Domain.
88

9-
# determine the domain name. there is only one domain directory.
10-
export DOMAIN_NAME=`ls /u01/oracle/user_projects/domains | head -1`
9+
PROPERTIES_FILE=/u01/oracle/properties/domain.properties
10+
if [ ! -e "$PROPERTIES_FILE" ]; then
11+
echo "A properties file with the username and password needs to be supplied."
12+
exit
13+
fi
14+
15+
DOMAIN_NAME=`awk '{print $1}' $PROPERTIES_FILE | grep ^DOMAIN_NAME= | cut -d "=" -f2`
16+
if [ -z "$DOMAIN_NAME" ]; then
17+
echo "The domain name is blank. The domain name must be set in the properties file."
18+
exit
19+
fi
20+
21+
USER=`awk '{print $1}' $PROPERTIES_FILE | grep ^username= | cut -d "=" -f2`
22+
if [ -z "$USER" ]; then
23+
echo "The domain username is blank. The Admin username must be set in the properties file."
24+
exit
25+
fi
26+
27+
PASS=`awk '{print $1}' $PROPERTIES_FILE | grep ^password= | cut -d "=" -f2`
28+
if [ -z "$PASS" ]; then
29+
echo "The domain password is blank. The Admin password must be set in the properties file."
30+
exit
31+
fi
1132

1233
#Define DOMAIN_HOME
1334
export DOMAIN_HOME=/u01/oracle/user_projects/domains/$DOMAIN_NAME
1435

36+
mkdir -p ${DOMAIN_HOME}/servers/AdminServer/security/
37+
echo "username=${USER}" >> $DOMAIN_HOME/servers/AdminServer/security/boot.properties
38+
echo "password=${PASS}" >> $DOMAIN_HOME/servers/AdminServer/security/boot.properties
39+
1540
# Start Admin Server and tail the logs
1641
${DOMAIN_HOME}/startWebLogic.sh
1742
touch ${DOMAIN_HOME}/servers/AdminServer/logs/AdminServer.log
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# These variables are used for substitution in the WDT model file.
2+
# The username and password variables are also used as admin credentials for server startup.
3+
username=weblogic
4+
password=welcome1
5+
DOMAIN_NAME=my_domain
6+
DB_USER=dba
7+
DB_PASSWORD=dba1
8+
NM_USER=weblogic
9+
NM_PASSWORD=welcome1
10+
ADMIN_PORT=7001
11+
ADMIN_HOST=wlsadmin

samples/docker-domain/simple-topology.yaml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
domainInfo:
2-
AdminUserName: '@@PROP:ADMIN_USER@@'
3-
AdminPassword: welcome1
4-
ServerStartMode: dev
2+
AdminUserName: '@@PROP:username@@'
3+
AdminPassword: '@@PROP:password@@'
4+
ServerStartMode: prod
55
topology:
66
Name: '@@PROP:DOMAIN_NAME@@'
77
AdminServerName: AdminServer
@@ -12,7 +12,6 @@ topology:
1212
DynamicServers:
1313
ServerTemplate: template1
1414
CalculatedListenPorts: false
15-
MaximumDynamicServerCount: 2
1615
ServerNamePrefix: 'ms-'
1716
DynamicClusterSize: 2
1817
MaxDynamicClusterSize: 8
@@ -32,8 +31,8 @@ topology:
3231
ListenPort: 5556
3332
Notes: The only node manager
3433
SecurityConfiguration:
35-
NodeManagerUsername: weblogic
36-
NodeManagerPasswordEncrypted: welcome1
34+
NodeManagerUsername: '@@PROP:NM_USER@@'
35+
NodeManagerPasswordEncrypted: '@@PROP:NM_PASSWORD@@'
3736
JMX:
3837
InvocationTimeoutSeconds: 40
3938
Notes: JMX notes
@@ -52,10 +51,10 @@ resources:
5251
JDBCDriverParams:
5352
DriverName: oracle.jdbc.xa.client.OracleXADataSource
5453
URL: 'jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=slc05til.us.oracle.com)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=orcl.us.oracle.com)))'
55-
PasswordEncrypted: welcome1
54+
PasswordEncrypted: '@@PROP:DB_PASSWORD@@'
5655
Properties:
5756
user:
58-
Value: jshum
57+
Value: '@@PROP:DB_USER@@'
5958
oracle.net.CONNECT_TIMEOUT:
6059
Value: 5000
6160
oracle.jdbc.ReadTimeout:

0 commit comments

Comments
 (0)