Skip to content

Commit eb6bf9f

Browse files
authoredDec 7, 2018
Merge pull request #196 from oracle/Issue#OWLS-69931-align-docker-sample-with-operator
Issue#owls 69931 align docker sample with operator
2 parents e2b0063 + 218213c commit eb6bf9f

File tree

14 files changed

+431
-200
lines changed

14 files changed

+431
-200
lines changed
 

‎samples/docker-domain/Dockerfile

Lines changed: 104 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#Copyright (c) 2014-2018 Oracle and/or its affiliates. All rights reserved.
1+
#Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
22
#
33
#Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
44
#
@@ -11,88 +11,138 @@
1111
#
1212
# HOW TO BUILD THIS IMAGE
1313
# -----------------------
14-
# Put all downloaded files in the same directory as this Dockerfile
14+
1515
# Build the deployment archive file using the build-archive.sh script.
1616
# $ ./build-archive.sh
1717
#
1818
# Run:
1919
# $ sudo docker build \
20+
# --build-arg CUSTOM_ADMIN_HOST=wlsadmin \
21+
# --build-arg CUSTOM_ADMIN_PORT=7001 \
22+
# --build-arg CUSTOM_ADMIN_NAME=7001 \
23+
# --build-arg CUSTOM_MANAGED_SERVER_PORT=8001 \
24+
# --build-arg CUSTOM_DOMAIN_NAME=base_domain \
25+
# --build-arg CUSTOM_DEBUG_PORT=8453 \
2026
# --build-arg WDT_MODEL=simple-topology.yaml \
2127
# --build-arg WDT_ARCHIVE=archive.zip \
28+
# --build-arg WDT_VARIABLE=properties/docker-build/domain.properties \
2229
# --force-rm=true \
2330
# -t 12213-domain-wdt .
2431
#
32+
# If the ADMIN_HOST, ADMIN_PORT, MS_PORT, DOMAIN_NAME are not provided, the variables
33+
# are set to default values. (The values shown in the build statement).
34+
#
35+
# You must insure that the build arguments align with the values in the model.
36+
# The sample model replaces the attributes with tokens that are resolved from values in the
37+
# corresponding property file domain.properties. The container-scripts/setEnv.sh script
38+
# demonstrates parsing the variable file to build a string of --build-args that can
39+
# be passed on the docker build command.
40+
#
2541
# Pull base image
2642
# ---------------
2743
# FROM store/oracle/weblogic:12.2.1.3
28-
FROM oracle/weblogic:12.2.1.3-developer
44+
FROM store/oracle/weblogic:12.2.1.3-dev
2945

3046
# Maintainer
3147
# ----------
32-
MAINTAINER Monica Riccelli <monica.riccelli@oracle.com>
48+
MAINTAINER Richard Killen <richard.killen@oracle.com>
3349

34-
ARG WDT_MODEL
3550
ARG WDT_ARCHIVE
51+
ARG WDT_VARIABLE
52+
ARG WDT_MODEL
53+
ARG CUSTOM_ADMIN_NAME=admin-server
54+
ARG CUSTOM_ADMIN_HOST=wlsadmin
55+
ARG CUSTOM_ADMIN_PORT=7001
56+
ARG CUSTOM_MANAGED_SERVER_PORT=8001
57+
ARG CUSTOM_DOMAIN_NAME=base_domain
58+
ARG CUSTOM_DEBUG_PORT=8453
3659

37-
# WLS Configuration
60+
# Persist arguments - for ports to expose and container to use
61+
# Create a placeholder for the manager server name. This will be provided when run the container
62+
# Weblogic and Domain locations
63+
# Set the start derby in admin server flag to true. Override this in the runtime properties
64+
# The boot.properties will be created under the DOMAIN_HOME when the admin server container is run
65+
# WDT installation
3866
# ---------------------------
39-
ENV ADMIN_HOST="wlsadmin" \
40-
NM_PORT="5556" \
41-
MS_PORT="8001" \
42-
DEBUG_PORT="8453" \
67+
ENV ADMIN_NAME=${CUSTOM_ADMIN_NAME} \
68+
ADMIN_HOST=${CUSTOM_ADMIN_HOST} \
69+
ADMIN_PORT=${CUSTOM_ADMIN_PORT} \
70+
MANAGED_SERVER_NAME=${MANAGED_SERVER_NAME} \
71+
MANAGED_SERVER_PORT=${CUSTOM_MANAGED_SERVER_PORT} \
72+
DEBUG_PORT=${CUSTOM_DEBUG_PORT} \
73+
DERBY_FLAG="true" \
4374
ORACLE_HOME=/u01/oracle \
44-
SCRIPT_FILE=/u01/oracle/createAndStartWLSDomain.sh \
45-
CONFIG_JVM_ARGS="-Dweblogic.security.SSL.ignoreHostnameVerification=true" \
46-
PATH=$PATH:/u01/oracle/oracle_common/common/bin:/u01/oracle/wlserver/common/bin:/u01/oracle/user_projects/domains/${DOMAIN_NAME:-base_domain}/bin:/u01/oracle
47-
48-
# Domain and Server environment variables
49-
# ------------------------------------------------------------
50-
ENV DOMAIN_NAME="${DOMAIN_NAME:-base_domain}" \
51-
PRE_DOMAIN_HOME=/u01/oracle/user_projects \
52-
ADMIN_PORT="${ADMIN_PORT:-7001}" \
53-
WDT_MODEL="$WDT_MODEL" \
54-
WDT_ARCHIVE="$WDT_ARCHIVE"
75+
DOMAIN_NAME=${CUSTOM_DOMAIN_NAME} \
76+
DOMAIN_PARENT=${ORACLE_HOME}/user_projects/domains
5577

56-
# Add files required to build this image
57-
COPY container-scripts/* /u01/oracle/
58-
COPY weblogic-deploy.zip /u01
59-
COPY ${WDT_MODEL} ${ARCHIVE_FILE} /u01/
78+
ENV DOMAIN_HOME=${DOMAIN_PARENT}/${DOMAIN_NAME} \
79+
PROPERTIES_FILE_DIR=$ORACLE_HOME/properties \
80+
WDT_HOME="/u01" \
81+
SCRIPT_HOME="${ORACLE_HOME}" \
82+
PATH=$PATH:${ORACLE_HOME}/oracle_common/common/bin:${ORACLE_HOME}/wlserver/common/bin:${DOMAIN_HOME}:${DOMAIN_HOME}/bin:${ORACLE_HOME}
6083

61-
# this file contains credentials.
62-
# be sure to build with --force-rm to eliminate this container layer
63-
COPY properties /u01/oracle
84+
COPY weblogic-deploy.zip ${WDT_HOME}
85+
COPY container-scripts/* ${SCRIPT_HOME}/
6486

65-
# Create directory where domain will be written to
87+
# Create the properties file directory and the domain home parent with the correct permissions / owner.
88+
# Unzip and install the WDT image and change the permissions / owner.
6689
USER root
67-
RUN chmod +xw /u01/oracle/*.sh && \
68-
chmod +xw /u01/oracle/*.py && \
69-
mkdir -p $PRE_DOMAIN_HOME && \
70-
mkdir -p $PRE_DOMAIN_HOME/domains && \
71-
chmod a+xr $PRE_DOMAIN_HOME && \
72-
chown -R oracle:oracle $PRE_DOMAIN_HOME && \
73-
cd /u01 && \
74-
$JAVA_HOME/bin/jar xf /u01/weblogic-deploy.zip && \
75-
chmod +xw /u01/weblogic-deploy/bin/*.sh && \
76-
chmod -R +xw /u01/weblogic-deploy/lib/python && \
77-
if [ -n "$WDT_MODEL" ]; then MODEL_OPT="-model_file /u01/$WDT_MODEL"; fi && \
78-
if [ -n "$WDT_ARCHIVE" ]; then ARCHIVE_OPT="-archive_file /u01/$WDT_ARCHIVE"; fi && \
79-
/u01/weblogic-deploy/bin/createDomain.sh \
90+
RUN chmod +xw $SCRIPT_HOME/*.sh && \
91+
chown -R oracle:oracle ${SCRIPT_HOME} && \
92+
mkdir -p +xwr $PROPERTIES_FILE_DIR && \
93+
chown -R oracle:oracle $PROPERTIES_FILE_DIR && \
94+
mkdir -p $DOMAIN_PARENT && \
95+
chown -R oracle:oracle $DOMAIN_PARENT && \
96+
chmod -R a+xwr $DOMAIN_PARENT && \
97+
cd ${WDT_HOME} && \
98+
$JAVA_HOME/bin/jar xf ./weblogic-deploy.zip && \
99+
rm weblogic-deploy.zip && \
100+
chmod +xw weblogic-deploy/bin/*.sh && \
101+
chmod -R +xw weblogic-deploy/lib/python && \
102+
chown -R oracle:oracle weblogic-deploy
103+
104+
# Persist the WDT tool home location
105+
ENV WDT_HOME=$WDT_HOME/weblogic-deploy
106+
107+
# Copy the WDT model, archive file, variable file and credential secrets to the property file directory.
108+
# These files will be removed after the image is built.
109+
# Be sure to build with --force-rm to eliminate this container layer
110+
111+
COPY ${WDT_MODEL} ${WDT_ARCHIVE} ${WDT_VARIABLE} properties/docker-build/*.properties ${PROPERTIES_FILE_DIR}/
112+
# --chown for COPY is available in docker version 18 'COPY --chown oracle:oracle'
113+
RUN chown -R oracle:oracle ${PROPERTIES_FILE_DIR}
114+
115+
# Create the domain home in the docker image.
116+
#
117+
# The create domain tool creates a domain at the DOMAIN_HOME location
118+
# The domain name is set using the value in the model / variable files
119+
# The domain name can be different from the DOMAIN_HOME domain folder name.
120+
#
121+
# Set WORKDIR for @@PWD@@ global token in model file
122+
WORKDIR $ORACLE_HOME
123+
USER oracle
124+
RUN if [ -n "$WDT_MODEL" ]; then MODEL_OPT="-model_file $PROPERTIES_FILE_DIR/${WDT_MODEL##*/}"; fi && \
125+
if [ -n "$WDT_ARCHIVE" ]; then ARCHIVE_OPT="-archive_file $PROPERTIES_FILE_DIR/${WDT_ARCHIVE##*/}"; fi && \
126+
if [ -n "$WDT_VARIABLE" ]; then VARIABLE_OPT="-variable_file $PROPERTIES_FILE_DIR/${WDT_VARIABLE##*/}"; fi && \
127+
${WDT_HOME}/bin/createDomain.sh \
80128
-oracle_home $ORACLE_HOME \
81-
-java_home ${JAVA_HOME} \
82-
-domain_parent $PRE_DOMAIN_HOME/domains \
129+
-java_home $JAVA_HOME \
130+
-domain_home $DOMAIN_HOME \
83131
-domain_type WLS \
84-
-variable_file /u01/oracle/domain.properties \
132+
$VARIABLE_OPT \
85133
$MODEL_OPT \
86134
$ARCHIVE_OPT && \
87-
chown -R oracle:oracle $PRE_DOMAIN_HOME && \
88-
rm /u01/oracle/domain.properties
135+
chmod -R a+x $DOMAIN_HOME/bin/*.sh && \
136+
rm -rf $PROPERTIES_FILE_DIR
89137

90-
VOLUME $PRE_DOMAIN_HOME
91-
# Expose Node Manager default port, and also default for admin and managed server
92-
EXPOSE $NM_PORT $ADMIN_PORT $MS_PORT $DEBUG_PORT
138+
# Mount the domain home and the WDT home for easy access.
139+
VOLUME $DOMAIN_HOME
140+
VOLUME $WDT_HOME
93141

94-
USER oracle
95-
WORKDIR $ORACLE_HOME
142+
# Expose admin server, managed server port and domain debug port
143+
EXPOSE $ADMIN_PORT $MANAGED_SERVER_PORT $DEBUG_PORT
144+
145+
WORKDIR $DOMAIN_HOME
96146

97-
# Define default command to start bash.
98-
CMD ["/u01/oracle/startWLSDomain.sh"]
147+
# Define default command to start Admin Server in a container.
148+
CMD ["/u01/oracle/startAdminServer.sh"]

‎samples/docker-domain/README.md

Lines changed: 66 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@ This sample includes a basic WDT model, `simple-topology.yaml`, that describes t
1212

1313
Another option is to use the WDT `discoverDomain` tool to create a model. This process is also described in the WDT project's README file. A user can use the tool to analyze an existing domain, and create a model based on its configuration. The user may choose to customize the model before using it to create a new Docker image.
1414

15+
The sample model is accompanied by a properties file whose values can be changed to customize a domain. The model's variable tokens are replaced with values from 'simple-topology.properties' when building the docker image. The properties files can be created and modified using a text editor. Select variables in the properties file are used by the Dockerfile during the build to persist ENV variables and expose ports in the image.
16+
17+
Care should be taken to secure the credentials that are present in the model. The ADMIN credential attributes in the sample model have a file token referencing a special property file. Each special property file must only contain a single property and can be created and modified using a text editor. The sample includes the files adminuser.properties and the adminpass.properties in the properties/docker_build directory.
18+
19+
See the README file for more information on using property and file tokens in the WDT model.
20+
21+
The ADMIN credentials are necessary to start the Admin or Managed Server in a docker container. The sample provides security.properties in the properties/docker-run directory. This file contains the admin credentials and additional properties used to customize the Weblogic Server start.
22+
23+
Note: Oracle recommends that the adminpass.properties, adminuser.properties and security.properties files be deleted or secured after the image is built and the WebLogic Server are started so that the user name and password are not inadvertently exposed.
24+
1525
Domain creation may require the deployment of applications and libraries. This is accomplished by creating a ZIP archive with a specific structure, then referencing those items in the model. This sample creates and deploys a simple ZIP archive containing a small application WAR. That archive is built in the sample directory prior to creating the Docker image.
1626

1727
When the WDT `discoverDomain` tool is used on an existing domain, a ZIP archive is created containing any necessary applications and libraries. The corresponding configuration for those applications and libraries is added to the model.
@@ -28,27 +38,76 @@ This sample deploys a simple, one-page web application contained in a ZIP archiv
2838

2939
$ ./build-archive.sh
3040

31-
To build this sample, run:
41+
The sample requires the Admin Host, Admin Port and Admin Name. It also requires the Managed Server port and the domain Debug
42+
Port. The ports will be EXPOSED through Docker. The other arguments are persisted in the image to be used when running a
43+
container. If an attribute is not provided as a --build-arg on the build command, the following defaults are set.
44+
45+
CUSTOM_ADMIN_NAME = admin-server
46+
The value is persisted to the image as ADMIN_NAME
47+
48+
CUSTOM_ADMIN_HOST = wlsadmin
49+
The value is persisted to the image as ADMIN_HOST
50+
51+
CUSTOM_ADMIN_PORT = 7001
52+
The value is persisted to the image as ADMIN_PORT
53+
54+
CUSTOM_MANAGED_SERVER_PORT = 8001
55+
The value is persisted to the image as MANAGED_SERVER_PORT
56+
57+
CUSTOM_DEBUG_PORT = 8453
58+
The value is persisted to the image as DEBUG_PORT
59+
60+
CUSTOM_DOMAIN_NAME = base_domain
61+
The value is persisted to the image as DOMAIN_NAME
62+
63+
To build this sample taking the defaults, run:
3264

3365
$ docker build \
3466
--build-arg WDT_MODEL=simple-topology.yaml \
3567
--build-arg WDT_ARCHIVE=archive.zip \
68+
--build-arg WDT_VARIABLE=properties/docker-build/domain.properties \
3669
--force-rm=true \
3770
-t 12213-domain-wdt .
3871

39-
This will use the model file and archive in the sample directory.
72+
This will use the model, variable and archive files in the sample directory.
73+
74+
This sample provides a script which will read the model variable file and parse the domain, admin and managed server information
75+
into a string of --build-arg statements. This build arg string is exported as environment variable BUILD_ARG.
76+
The sample script specifically parses the sample variable file. Use it as an example to parse a custom variable file.
77+
This will insure that the values docker exposes and persists in the image are the same values configured in the domain.
78+
79+
To parse the sample variable file and build the sample, run:
80+
81+
$ container-scripts/setEnv.sh properties/docker-build/domain.properties
82+
83+
$ docker build \
84+
$BUILD_ARG \
85+
--build-arg WDT_MODEL=simple-topology.yaml \
86+
--build-arg WDT_ARCHIVE=archive.zip \
87+
--build-arg WDT_VARIABLE=properties/docker-build/domain.properties \
88+
--force-rm=true \
89+
-t 12213-domain-wdt .
90+
91+
This sample provides a Derby Data Source that is targeted to the Managed Server cluster. The Derby database is created
92+
in the Admin Server container when the container is run. To turn off the database create, set DERBY_FLAG="false" in the
93+
runtime security.properties used on the docker run statement.
94+
95+
The Admin Server and each Managed Server are run in containers from this build image. In the sample, the securities.properties file
96+
is provided on the docker run command. In addition to the credentials and DERBY_FLAG, the file contains the JAVA_OPTS for the
97+
running Admin or Managed server. Mount the properties/docker-run directory to the container so that file can be accessed by the
98+
server start script. It is the responsibility of the user to manage this volume, and the security.properties, in the container.
4099

41100
To start the containerized Administration Server, run:
42101

43-
$ docker run -d --name wlsadmin --hostname wlsadmin -p 7001:7001 -v <sample-directory>/properties:/u01/oracle/properties 12213-domain-wdt
102+
$ docker run -d --name wlsadmin --hostname wlsadmin -p 7001:7001 -v <sample-directory>/properties/docker_run:/u01/oracle/properties 12213-domain-wdt
44103

45-
To start a containerized Managed Server (ms-1) to self-register with the Administration Server above, run:
104+
To start a containerized Managed Server (managed-server-1) to self-register with the Administration Server above, run:
46105

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
106+
$ docker run -d --name managed-server-1 --link wlsadmin:wlsadmin -p 9001:9001 -v <sample-directory>/properties/docker_run:/u01/oracle/properties -e MANAGED_SERVER_NAME=managed-server-1 12213-domain-wdt startManagedServer.sh
48107

49-
To start an additional Managed Server (in this example ms-2), run:
108+
To start an additional Managed Server (in this example managed-server-2), run:
50109

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
110+
$ docker run -d --name managed-server-2 --link wlsadmin:wlsadmin -p 9002:9001 -v <sample-directory>/properties/docker_run/:/u01/oracle/properties -e MANAGED_SERVER_NAME=managed-server-2 12213-domain-wdt startManagedServer.sh
52111

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

‎samples/docker-domain/build.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,17 @@
44
#
55
#Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
66
#
7+
8+
# parse the ADMIN_HOST, ADMIN_PORT, MS_PORT, and DOMAIN_NAME from the sample properties file and pass
9+
# as a string of --build-arg in the variable BUILD_ARG
10+
. container-scripts/setEnv.sh properties/docker-build/domain.properties
11+
12+
713
docker build \
14+
$BUILD_ARG \
815
--build-arg WDT_MODEL=simple-topology.yaml \
16+
--build-arg WDT_VARIABLE=properties/docker-build/domain.properties \
917
--build-arg WDT_ARCHIVE=archive.zip \
18+
--force-rm=true \
1019
-t 12213-domain-wdt .
1120

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/bin/bash ex
2+
3+
# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
4+
# The Universal Permissive License (UPL), Version 1.0
5+
#
6+
# This example creates the BUILD_ARG environment variable as a string of --build-arg for
7+
# the arguments passed on the docker build command. The variable file that is used for the WDT
8+
# create domain step is the input to this script. This insures that the values persisted
9+
# as environment variables in the docker image match the configured domain home.
10+
11+
BUILD_ARG=''
12+
if [ $# > 1 ]; then
13+
PROPERTIES_FILE=$1
14+
fi
15+
16+
if [ ! -e "${PROPERTIES_FILE}" ]; then
17+
echo "A properties file with variable definitions should be supplied."
18+
fi
19+
20+
echo Export environment variables from the ${PROPERTIES_FILE} properties file
21+
22+
DOMAIN_DIR=`awk '{print $1}' $PROPERTIES_FILE | grep ^DOMAIN_NAME= | cut -d "=" -f2`
23+
if [ ! -n "$DOMAIN_DIR" ]; then
24+
if [ -n "$DOMAIN_NAME" ]; then
25+
DOMAIN_DIR=$DOMAIN_NAME
26+
fi
27+
fi
28+
if [ -n "$DOMAIN_DIR" ]; then
29+
DOMAIN_NAME=$DOMAIN_DIR
30+
export DOMAIN_NAME
31+
echo DOMAIN_NAME=$DOMAIN_NAME
32+
BUILD_ARG="$BUILD_ARG --build-arg CUSTOM_DOMAIN_NAME=$DOMAIN_NAME"
33+
fi
34+
35+
ADMIN_HOST=`awk '{print $1}' $PROPERTIES_FILE | grep ^ADMIN_HOST= | cut -d "=" -f2`
36+
if [ -n "$ADMIN_HOST" ]; then
37+
export ADMIN_HOST
38+
echo ADMIN_HOST=$ADMIN_HOST
39+
BUILD_ARG="$BUILD_ARG --build-arg CUSTOM_ADMIN_HOST=$ADMIN_HOST"
40+
fi
41+
42+
ADMIN_NAME=`awk '{print $1}' $PROPERTIES_FILE | grep ^ADMIN_NAME= | cut -d "=" -f2`
43+
if [ -n "$ADMIN_NAME" ]; then
44+
export ADMIN_NAME
45+
echo ADMIN_NAME=$ADMIN_NAME
46+
BUILD_ARG="$BUILD_ARG --build-arg CUSTOM_ADMIN_NAME=$ADMIN_NAME"
47+
fi
48+
49+
ADMIN_PORT=`awk '{print $1}' $PROPERTIES_FILE | grep ^ADMIN_PORT= | cut -d "=" -f2`
50+
if [ -n "$ADMIN_PORT" ]; then
51+
export ADMIN_PORT
52+
echo ADMIN_PORT=$ADMIN_PORT
53+
BUILD_ARG="$BUILD_ARG --build-arg CUSTOM_ADMIN_PORT=$ADMIN_PORT"
54+
fi
55+
56+
MANAGED_SERVER_PORT=`awk '{print $1}' $PROPERTIES_FILE | grep ^MANAGED_SERVER_PORT= | cut -d "=" -f2`
57+
if [ -n "$MANAGED_SERVER_PORT" ]; then
58+
export MANAGED_SERVER_PORT
59+
echo MANAGED_SERVER_PORT=$MANAGED_SERVER_PORT
60+
BUILD_ARG="$BUILD_ARG --build-arg CUSTOM_MANAGED_SERVER_PORT=$MANAGED_SERVER_PORT"
61+
fi
62+
63+
DEBUG_PORT=`awk '{print $1}' $PROPERTIES_FILE | grep ^DEBUG_PORT= | cut -d "=" -f2`
64+
if [ -n "$DEBUG_PORT" ]; then
65+
export DEBUG_PORT
66+
echo DEBUG_PORT=$DEBUG_PORT
67+
BUILD_ARG="$BUILD_ARG --build-arg CUSTOM_DEBUG_PORT=$DEBUG_PORT"
68+
fi
69+
70+
echo BUILD_ARG=$BUILD_ARG
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/bin/bash
2+
#
3+
#Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
4+
#
5+
#Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
6+
#
7+
# Start the domain Admin Server.
8+
9+
# Locate the runtime properties
10+
PROPERTIES_FILE=${PROPERTIES_FILE_DIR}/security.properties
11+
if [ ! -e "$PROPERTIES_FILE" ]; then
12+
echo "A security.properties file with the username and password needs to be supplied."
13+
exit
14+
fi
15+
16+
# Define Admin Server JAVA_OPTIONS
17+
JAVA_OPTIONS=`awk '{print $1}' $PROPERTIES_FILE | grep ^JAVA_OPTIONS= | cut -d "=" -f2`
18+
if [ -z "${JAVA_OPTIONS}" ]; then
19+
JAVA_OPTIONS="-Dweblogic.StdoutDebugEnabled=false"
20+
fi
21+
export ${JAVA_OPTIONS}
22+
echo "Java Options: ${JAVA_OPTIONS}"
23+
24+
# Define start of Derby Database
25+
CUSTOM_DERBY_FLAG=`awk '{print $1}' $PROPERTIES_FILE | grep ^DERBY_FLAG= | cut -d "=" -f2`
26+
if [ -n "${CUSTOM_DERBY_FLAG}" ]; then
27+
DERBY_FLAG="${CUSTOM_DERBY_FLAG}"
28+
fi
29+
30+
export ${DERBY_FLAG}
31+
echo "Start Derby: ${DERBY_FLAG}"
32+
33+
export AS_HOME="${DOMAIN_HOME}/servers/${ADMIN_NAME}"
34+
export AS_SECURITY="${AS_HOME}/security"
35+
export AS_LOGS="${AS_HOME}/logs"
36+
37+
if [ -f ${AS_LOGS}}/${ADMIN_NAME}.log ]; then
38+
exit
39+
fi
40+
41+
echo "Admin Server Home: ${AS_HOME}"
42+
echo "Admin Server Security: ${AS_SECURITY}"
43+
echo "Admin Server Logs: ${AS_LOGS}"
44+
45+
USER=`awk '{print $1}' $PROPERTIES_FILE | grep ^username= | cut -d "=" -f2`
46+
if [ -z "$USER" ]; then
47+
echo "The domain username is blank. The Admin username must be set in the properties file."
48+
exit 1
49+
fi
50+
51+
PASS=`awk '{print $1}' $PROPERTIES_FILE | grep ^password= | cut -d "=" -f2`
52+
if [ -z "$PASS" ]; then
53+
echo "The domain password is blank. The Admin password must be set in the properties file."
54+
exit 1
55+
fi
56+
57+
mkdir -p ${AS_SECURITY}
58+
echo "username=${USER}" >> ${AS_SECURITY}/boot.properties
59+
echo "password=${PASS}" >> ${AS_SECURITY}/boot.properties
60+
61+
# Start Admin Server and tail the logs
62+
${DOMAIN_HOME}/bin/setDomainEnv.sh
63+
${DOMAIN_HOME}/startWebLogic.sh
64+
65+
tail -f ${AS_LOGS}/${ADMIN_NAME}.log &
66+
67+
childPID=$!
68+
wait $childPID
Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,42 @@
11
#!/bin/bash
22
#
3-
#Copyright (c) 2014-2018 Oracle and/or its affiliates. All rights reserved.
3+
#Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
44
#
55
#Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
66
#
7-
# Start the Domain.
7+
# Start a Domain Managed Server.
88

9-
PROPERTIES_FILE=/u01/oracle/properties/domain.properties
9+
PROPERTIES_FILE=${PROPERTIES_FILE_DIR}/security.properties
1010
if [ ! -e "$PROPERTIES_FILE" ]; then
11-
echo "A properties file with variable definitions needs to be supplied."
11+
echo "A security.properties file with variable definitions needs to be supplied."
1212
exit
1313
fi
1414

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."
15+
JAVA_OPTIONS=`awk '{print $1}' $PROPERTIES_FILE | grep ^JAVA_OPTIONS= | cut -d "=" -f2`
16+
if [ -z "$JAVA_OPTIONS" ]; then
17+
JAVA_OPTIONS="-Dweblogic.StdoutDebugEnabled=false"
18+
fi
19+
20+
export MS_HOME="${DOMAIN_HOME}/servers/${MANAGED_SERVER_NAME}"
21+
export MS_SECURITY="${MS_HOME}/security"
22+
export MS_LOGS="${MS_HOME}/logs"
23+
24+
if [ -f ${MS_LOGS}/${MANAGED_SERVER_NAME}.log ]; then
1825
exit
1926
fi
2027

28+
# Wait for the domain Admin Server to become available
29+
${SCRIPT_HOME}/waitForAdminServer.sh
30+
31+
echo "Managed Server Name: ${MANAGED_SERVER_NAME}"
32+
echo "Managed Server Home: ${MS_HOME}"
33+
echo "Managed Server Security: ${MS_SECURITY}"
34+
echo "Managed Server Logs: ${MS_LOGS}"
35+
2136
USER=`awk '{print $1}' $PROPERTIES_FILE | grep ^username= | cut -d "=" -f2`
2237
if [ -z "$USER" ]; then
2338
echo "The admin username is blank. The admin username must be set in the properties file."
24-
exit
39+
exit
2540
fi
2641

2742
PASS=`awk '{print $1}' $PROPERTIES_FILE | grep ^password= | cut -d "=" -f2`
@@ -30,29 +45,17 @@ if [ -z "$PASS" ]; then
3045
exit
3146
fi
3247

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-
45-
#Define DOMAIN_HOME
46-
export DOMAIN_HOME=/u01/oracle/user_projects/domains/$DOMAIN_NAME
48+
mkdir -p ${MS_SECURITY}
49+
echo username=$USER > ${MS_SECURITY}/boot.properties
50+
echo password=$PASS >> ${MS_SECURITY}/boot.properties
4751

48-
mkdir -p $DOMAIN_HOME/servers/$MS_NAME/security
49-
echo username=$USER > $DOMAIN_HOME/servers/$MS_NAME/security/boot.properties
50-
echo password=$PASS >> $DOMAIN_HOME/servers/$MS_NAME/security/boot.properties
52+
# Start Managed Server
53+
${DOMAIN_HOME}/bin/setDomainEnv.sh
54+
echo 'Start Managed Server: ${MANAGED_SERVER_NAME}'
55+
${DOMAIN_HOME}/bin/startManagedWebLogic.sh ${MANAGED_SERVER_NAME} http://${ADMIN_HOST}:${ADMIN_PORT}
5156

52-
# Start Managed Server and tail the logs
53-
${DOMAIN_HOME}/bin/startManagedWebLogic.sh $MS_NAME http://$ADMIN_HOST:$ADMIN_PORT
54-
touch ${DOMAIN_HOME}/servers/$MS_NAME/logs/${MS_NAME}.log
55-
tail -f ${DOMAIN_HOME}/servers/$MS_NAME/logs/${MS_NAME}.log &
57+
# Tail Managed Server Log
58+
tail -f ${MS_LOGS}/${MANAGED_SERVER_NAME}.log &
5659

5760
childPID=$!
5861
wait $childPID

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

Lines changed: 0 additions & 46 deletions
This file was deleted.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
#
3+
#Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
4+
#
5+
#Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
6+
#
7+
# This script will wait until Admin Server is available.
8+
# There is no timeout!
9+
#
10+
echo "Waiting for WebLogic Admin Server on $ADMIN_HOST:$ADMIN_PORT to become available..."
11+
while :
12+
do
13+
(echo > /dev/tcp/$ADMIN_HOST/$ADMIN_PORT) >/dev/null 2>&1
14+
available=$?
15+
if [[ $available -eq 0 ]]; then
16+
echo "WebLogic Admin Server is now available. Proceeding..."
17+
break
18+
fi
19+
sleep 1
20+
done
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
welcome1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
weblogic
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# These variables are used for substitution in the WDT model file.
2+
# Any port that will be exposed through Docker is put in this file.
3+
# The sample Dockerfile will get the ports from this file and not the WDT model.
4+
DOMAIN_NAME=domain1
5+
ADMIN_PORT=7001
6+
ADMIN_NAME=admin-server
7+
ADMIN_HOST=wlsadmin
8+
MANAGED_SERVER_PORT=8001
9+
MANAGED_SERVER_NAME_BASE=managed-server-
10+
CONFIGURED_MANAGED_SERVER_COUNT=2
11+
CLUSTER_NAME=cluster-1
12+
DEBUG_PORT=8453
13+
DEBUG_FLAG=true
14+
PRODUCTION_MODE_ENABLED=true
15+
CLUSTER_TYPE=DYNAMIC
16+
JAVA_OPTIONS=-Dweblogic.StdoutDebugEnabled=false
17+
T3_CHANNEL_PORT=30012
18+
T3_PUBLIC_ADDRESS=kubernetes
19+
SERVER_START_MODE=prod
20+
CLUSTER_ADMIN=cluster-1,admin-server
21+
# Derby Data Source parameters
22+
dsname=DockerDS
23+
dsdbname=DerbyDB;create=true
24+
dsjndiname=DockerDS
25+
dsdriver=org.apache.derby.jdbc.ClientXADataSource
26+
dsurl=jdbc:derby://localhost:1527/DerbyDB;create=true
27+
dbusername=dba
28+
dbpassword=dba1
29+
dstestquery=SQL SELECT 1 FROM SYS.SYSTABLES
30+
dsinitalcapacity=1
31+
dsmaxcapacity=15
32+
33+
34+
35+
36+
37+
#Derby Data Source parameters
38+
dsname=DockerDS
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
username=weblogic
2+
password=welcome1
3+
JAVA_OPTIONS=-Dweblogic.StdoutDebugEnabled=false
4+
DERBY_FLAG=true

‎samples/docker-domain/properties/domain.properties

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 18 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,38 @@
11
domainInfo:
2-
AdminUserName: '@@PROP:username@@'
3-
AdminPassword: '@@PROP:password@@'
4-
ServerStartMode: prod
2+
AdminUserName: '@@FILE:/u01/oracle/properties/adminuser.properties@@'
3+
AdminPassword: '@@FILE:/u01/oracle/properties/adminpass.properties@@'
4+
ServerStartMode: '@@PROP:SERVER_START_MODE@@'
55
topology:
66
Name: '@@PROP:DOMAIN_NAME@@'
7-
AdminServerName: AdminServer
7+
AdminServerName: '@@PROP:ADMIN_NAME@@'
8+
ProductionModeEnabled: '@@PROP:PRODUCTION_MODE_ENABLED@@'
89
Cluster:
9-
mycluster:
10+
'@@PROP:CLUSTER_NAME@@':
1011
ClientCertProxyEnabled: true
11-
ClusterMessagingMode: unicast
1212
DynamicServers:
1313
ServerTemplate: template1
1414
CalculatedListenPorts: false
15-
ServerNamePrefix: 'ms-'
16-
DynamicClusterSize: 2
17-
MaxDynamicClusterSize: 8
15+
ServerNamePrefix: '@@PROP:MANAGED_SERVER_NAME_BASE@@'
16+
DynamicClusterSize: '@@PROP:CONFIGURED_MANAGED_SERVER_COUNT@@'
17+
MaxDynamicClusterSize: '@@PROP:CONFIGURED_MANAGED_SERVER_COUNT@@'
1818
Server:
19-
AdminServer:
20-
Machine: machine1
19+
'@@PROP:ADMIN_NAME@@':
2120
ListenPort: '@@PROP:ADMIN_PORT@@'
21+
NetworkAccessPoint:
22+
T3Channel:
23+
ListenAddress: None
24+
ListenPort: '@@PROP:T3_CHANNEL_PORT@@'
25+
PublicAddress: '@@PROP:T3_PUBLIC_ADDRESS@@'
26+
PublicPort: '@@PROP:T3_CHANNEL_PORT@@'
2227
ServerTemplate:
2328
template1:
24-
Machine: machine1
25-
ListenPort: 9001
26-
Machine:
27-
machine1:
28-
Notes: The only machine
29-
NodeManager:
30-
NMType: SSL
31-
ListenPort: 5556
32-
Notes: The only node manager
33-
SecurityConfiguration:
34-
NodeManagerUsername: '@@PROP:NM_USER@@'
35-
NodeManagerPasswordEncrypted: '@@PROP:NM_PASSWORD@@'
36-
JMX:
37-
InvocationTimeoutSeconds: 40
38-
Notes: JMX notes
39-
ManagedServerNotificationsEnabled: true
40-
JTA:
41-
MaxTransactions: 4
42-
Notes: JTA notes
43-
resources:
44-
JDBCSystemResource:
45-
Generic1:
46-
Target: mycluster
47-
JdbcResource:
48-
JDBCDataSourceParams:
49-
JNDIName: [ jdbc/generic1, jdbc/special1 ]
50-
GlobalTransactionsProtocol: TwoPhaseCommit
51-
JDBCDriverParams:
52-
DriverName: oracle.jdbc.xa.client.OracleXADataSource
53-
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)))'
54-
PasswordEncrypted: '@@PROP:DB_PASSWORD@@'
55-
Properties:
56-
user:
57-
Value: '@@PROP:DB_USER@@'
58-
oracle.net.CONNECT_TIMEOUT:
59-
Value: 5000
60-
oracle.jdbc.ReadTimeout:
61-
Value: 30000
62-
JDBCConnectionPoolParams:
63-
InitialCapacity: 0
64-
MaxCapacity: 15
29+
ListenPort: '@@PROP:MANAGED_SERVER_PORT@@'
6530
appDeployments:
6631
Application:
6732
# Quote needed because of hyphen in string
6833
'simple-app':
6934
SourcePath: 'wlsdeploy/applications/simple-app.war'
70-
Target: mycluster
35+
Target: '@@PROP:CLUSTER_NAME@@'
7136
ModuleType: war
7237
StagingMode: nostage
7338
PlanStagingMode: nostage

0 commit comments

Comments
 (0)
Please sign in to comment.