diff --git a/samples/docker-domain/Dockerfile b/samples/docker-domain/Dockerfile index 6501328819..2a88901cf7 100644 --- a/samples/docker-domain/Dockerfile +++ b/samples/docker-domain/Dockerfile @@ -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 # ---------- @@ -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 && \ @@ -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 diff --git a/samples/docker-domain/README.md b/samples/docker-domain/README.md index aa9e91bcb4..5a2935d3a3 100644 --- a/samples/docker-domain/README.md +++ b/samples/docker-domain/README.md @@ -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. @@ -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 /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= -e MS_NAME=ms-1 12213-domain-wdt startManagedServer.sh + $ docker run -d --name ms-1 --link wlsadmin:wlsadmin -p 9001:9001 -v /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= -e MS_NAME=ms-2 12213-domain-wdt startManagedServer.sh + $ docker run -d --name ms-2 --link wlsadmin:wlsadmin -p 9002:9001 -v /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. diff --git a/samples/docker-domain/container-scripts/domain.properties b/samples/docker-domain/container-scripts/domain.properties deleted file mode 100644 index 3bb3ba820b..0000000000 --- a/samples/docker-domain/container-scripts/domain.properties +++ /dev/null @@ -1,4 +0,0 @@ -DOMAIN_NAME=my_domain -ADMIN_PORT=7001 -ADMIN_HOST=wlsadmin -ADMIN_USER=weblogic diff --git a/samples/docker-domain/container-scripts/startManagedServer.sh b/samples/docker-domain/container-scripts/startManagedServer.sh index bb4a7c4e31..9cb591f765 100644 --- a/samples/docker-domain/container-scripts/startManagedServer.sh +++ b/samples/docker-domain/container-scripts/startManagedServer.sh @@ -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 diff --git a/samples/docker-domain/container-scripts/startWLSDomain.sh b/samples/docker-domain/container-scripts/startWLSDomain.sh index 660f04a101..b642a0c78f 100644 --- a/samples/docker-domain/container-scripts/startWLSDomain.sh +++ b/samples/docker-domain/container-scripts/startWLSDomain.sh @@ -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 diff --git a/samples/docker-domain/properties/domain.properties b/samples/docker-domain/properties/domain.properties new file mode 100644 index 0000000000..5caa5f3e6b --- /dev/null +++ b/samples/docker-domain/properties/domain.properties @@ -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 diff --git a/samples/docker-domain/simple-topology.yaml b/samples/docker-domain/simple-topology.yaml index 5b6bef2320..c37d8de231 100644 --- a/samples/docker-domain/simple-topology.yaml +++ b/samples/docker-domain/simple-topology.yaml @@ -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 @@ -12,7 +12,6 @@ topology: DynamicServers: ServerTemplate: template1 CalculatedListenPorts: false - MaximumDynamicServerCount: 2 ServerNamePrefix: 'ms-' DynamicClusterSize: 2 MaxDynamicClusterSize: 8 @@ -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 @@ -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: