Skip to content

Issue#134 access property file from mounted volume #135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions samples/docker-domain/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
# $ sudo docker build \
# --build-arg WDT_MODEL=simple-topology.yaml \
# --build-arg WDT_ARCHIVE=archive.zip \
# --force-rm=true \
# -t 12213-domain-wdt .
#
# Pull base image
# ---------------
FROM store/oracle/weblogic:12.2.1.3
# FROM store/oracle/weblogic:12.2.1.3
FROM oracle/weblogic:12.2.1.3-developer

# Maintainer
# ----------
Expand Down Expand Up @@ -56,7 +58,11 @@ COPY container-scripts/* /u01/oracle/
COPY weblogic-deploy.zip /u01
COPY ${WDT_MODEL} ${ARCHIVE_FILE} /u01/

#Create directory where domain will be written to
# this file contains credentials.
# be sure to build with --force-rm to eliminate this container layer
COPY properties /u01/oracle

# Create directory where domain will be written to
USER root
RUN chmod +xw /u01/oracle/*.sh && \
chmod +xw /u01/oracle/*.py && \
Expand All @@ -78,7 +84,8 @@ RUN chmod +xw /u01/oracle/*.sh && \
-variable_file /u01/oracle/domain.properties \
$MODEL_OPT \
$ARCHIVE_OPT && \
chown -R oracle:oracle $PRE_DOMAIN_HOME
chown -R oracle:oracle $PRE_DOMAIN_HOME && \
rm /u01/oracle/domain.properties

VOLUME $PRE_DOMAIN_HOME
# Expose Node Manager default port, and also default for admin and managed server
Expand Down
9 changes: 5 additions & 4 deletions samples/docker-domain/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ When the WDT discoverDomain tool is used on an existing domain, a ZIP archive is

### How to Build and Run

**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.
**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.

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

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

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

To start the containerized Administration Server, run:

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

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

$ 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
$ 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

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

$ 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
$ 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

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

Expand Down
4 changes: 0 additions & 4 deletions samples/docker-domain/container-scripts/domain.properties

This file was deleted.

40 changes: 38 additions & 2 deletions samples/docker-domain/container-scripts/startManagedServer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,48 @@
#
# Start the Domain.

PROPERTIES_FILE=/u01/oracle/properties/domain.properties
if [ ! -e "$PROPERTIES_FILE" ]; then
echo "A properties file with variable definitions needs to be supplied."
exit
fi

DOMAIN_NAME=`awk '{print $1}' $PROPERTIES_FILE | grep ^DOMAIN_NAME= | cut -d "=" -f2`
if [ -z "$DOMAIN_NAME" ]; then
echo "The domain name is blank. The domain name must be set in the properties file."
exit
fi

USER=`awk '{print $1}' $PROPERTIES_FILE | grep ^username= | cut -d "=" -f2`
if [ -z "$USER" ]; then
echo "The admin username is blank. The admin username must be set in the properties file."
exit
fi

PASS=`awk '{print $1}' $PROPERTIES_FILE | grep ^password= | cut -d "=" -f2`
if [ -z "$PASS" ]; then
echo "The admin password is blank. The admin password must be set in the properties file."
exit
fi

ADMIN_HOST=`awk '{print $1}' $PROPERTIES_FILE | grep ^ADMIN_HOST= | cut -d "=" -f2`
if [ -z "$ADMIN_HOST" ]; then
echo "The admin host is blank. The admin host must be set in the properties file."
exit
fi

ADMIN_PORT=`awk '{print $1}' $PROPERTIES_FILE | grep ^ADMIN_PORT= | cut -d "=" -f2`
if [ -z "$ADMIN_PORT" ]; then
echo "The admin port is blank. The admin port must be set in the properties file."
exit
fi

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

mkdir -p $DOMAIN_HOME/servers/$MS_NAME/security
echo username=$ADMIN_USER > $DOMAIN_HOME/servers/$MS_NAME/security/boot.properties
echo password=$ADMIN_PASSWORD >> $DOMAIN_HOME/servers/$MS_NAME/security/boot.properties
echo username=$USER > $DOMAIN_HOME/servers/$MS_NAME/security/boot.properties
echo password=$PASS >> $DOMAIN_HOME/servers/$MS_NAME/security/boot.properties

# Start Managed Server and tail the logs
${DOMAIN_HOME}/bin/startManagedWebLogic.sh $MS_NAME http://$ADMIN_HOST:$ADMIN_PORT
Expand Down
29 changes: 27 additions & 2 deletions samples/docker-domain/container-scripts/startWLSDomain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,37 @@
#
# Start the Domain.

# determine the domain name. there is only one domain directory.
export DOMAIN_NAME=`ls /u01/oracle/user_projects/domains | head -1`
PROPERTIES_FILE=/u01/oracle/properties/domain.properties
if [ ! -e "$PROPERTIES_FILE" ]; then
echo "A properties file with the username and password needs to be supplied."
exit
fi

DOMAIN_NAME=`awk '{print $1}' $PROPERTIES_FILE | grep ^DOMAIN_NAME= | cut -d "=" -f2`
if [ -z "$DOMAIN_NAME" ]; then
echo "The domain name is blank. The domain name must be set in the properties file."
exit
fi

USER=`awk '{print $1}' $PROPERTIES_FILE | grep ^username= | cut -d "=" -f2`
if [ -z "$USER" ]; then
echo "The domain username is blank. The Admin username must be set in the properties file."
exit
fi

PASS=`awk '{print $1}' $PROPERTIES_FILE | grep ^password= | cut -d "=" -f2`
if [ -z "$PASS" ]; then
echo "The domain password is blank. The Admin password must be set in the properties file."
exit
fi

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

mkdir -p ${DOMAIN_HOME}/servers/AdminServer/security/
echo "username=${USER}" >> $DOMAIN_HOME/servers/AdminServer/security/boot.properties
echo "password=${PASS}" >> $DOMAIN_HOME/servers/AdminServer/security/boot.properties

# Start Admin Server and tail the logs
${DOMAIN_HOME}/startWebLogic.sh
touch ${DOMAIN_HOME}/servers/AdminServer/logs/AdminServer.log
Expand Down
11 changes: 11 additions & 0 deletions samples/docker-domain/properties/domain.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# These variables are used for substitution in the WDT model file.
# The username and password variables are also used as admin credentials for server startup.
username=weblogic
password=welcome1
DOMAIN_NAME=my_domain
DB_USER=dba
DB_PASSWORD=dba1
NM_USER=weblogic
NM_PASSWORD=welcome1
ADMIN_PORT=7001
ADMIN_HOST=wlsadmin
15 changes: 7 additions & 8 deletions samples/docker-domain/simple-topology.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
domainInfo:
AdminUserName: '@@PROP:ADMIN_USER@@'
AdminPassword: welcome1
ServerStartMode: dev
AdminUserName: '@@PROP:username@@'
AdminPassword: '@@PROP:password@@'
ServerStartMode: prod
topology:
Name: '@@PROP:DOMAIN_NAME@@'
AdminServerName: AdminServer
Expand All @@ -12,7 +12,6 @@ topology:
DynamicServers:
ServerTemplate: template1
CalculatedListenPorts: false
MaximumDynamicServerCount: 2
ServerNamePrefix: 'ms-'
DynamicClusterSize: 2
MaxDynamicClusterSize: 8
Expand All @@ -32,8 +31,8 @@ topology:
ListenPort: 5556
Notes: The only node manager
SecurityConfiguration:
NodeManagerUsername: weblogic
NodeManagerPasswordEncrypted: welcome1
NodeManagerUsername: '@@PROP:NM_USER@@'
NodeManagerPasswordEncrypted: '@@PROP:NM_PASSWORD@@'
JMX:
InvocationTimeoutSeconds: 40
Notes: JMX notes
Expand All @@ -52,10 +51,10 @@ resources:
JDBCDriverParams:
DriverName: oracle.jdbc.xa.client.OracleXADataSource
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)))'
PasswordEncrypted: welcome1
PasswordEncrypted: '@@PROP:DB_PASSWORD@@'
Properties:
user:
Value: jshum
Value: '@@PROP:DB_USER@@'
oracle.net.CONNECT_TIMEOUT:
Value: 5000
oracle.jdbc.ReadTimeout:
Expand Down