Skip to content

Commit e32e988

Browse files
committed
Incorporating Monica's feedback comments
1 parent 6f7f485 commit e32e988

File tree

6 files changed

+71
-30
lines changed

6 files changed

+71
-30
lines changed

OracleWebLogic/samples/12212-msiserver/Dockerfile

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,23 @@ MAINTAINER Aseem Bajaj <aseem.bajaj@oracle.com>
2727
# Arguments
2828
# ---------
2929
ARG number_of_ms=10
30+
ARG domains_dir=wlserver/samples/domains
31+
ARG domain_name=msi-sample
32+
ARG ms_name_prefix=ms
33+
ARG ms_port=8011
34+
ARG prod_or_dev=dev
3035

3136
# Environment variables required for this build (do NOT change)
3237
# -------------------------------------------------------------
3338
ENV MW_HOME="$ORACLE_HOME" \
3439
PATH="$ORACLE_HOME/wlserver/server/bin:$ORACLE_HOME/wlserver/../oracle_common/modules/org.apache.ant_1.9.2/bin:$JAVA_HOME/jre/bin:$JAVA_HOME/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$ORACLE_HOME/oracle_common/common/bin:$ORACLE_HOME/wlserver/common/bin:$ORACLE_HOME/user_projects/domains/medrec/bin:$ORACLE_HOME/wlserver/samples/server/medrec/:$ORACLE_HOME/wlserver/samples/server/:$ORACLE_HOME/wlserver/../oracle_common/modules/org.apache.maven_3.2.5/bin" \
3540
NUMBER_OF_MS=$number_of_ms \
36-
DOMAINS_DIR=$ORACLE_HOME/wlserver/samples/domains \
37-
DOMAIN_NAME=msi-sample \
38-
DEFAULT_MS_NAME=ms1
41+
DOMAINS_DIR=$ORACLE_HOME/$domains_dir \
42+
DOMAIN_NAME=$domain_name \
43+
MS_NAME_PREFIX=$ms_name_prefix \
44+
DEFAULT_MS_NAME=${ms_name_prefix}1 \
45+
MS_PORT=$ms_port \
46+
PROD_OR_DEV=$prod_or_dev
3947

4048
# Copy scripts
4149
# --------------------------------
@@ -46,8 +54,8 @@ COPY container-scripts/* /u01/oracle/
4654
# ---------------------------------------------
4755
RUN . $ORACLE_HOME/wlserver/server/bin/setWLSEnv.sh && \
4856
cd /u01/oracle && \
49-
./provision-domain-for-msi.sh $DOMAIN_NAME $ORACLE_HOME/wlserver/common/templates/wls/wls.jar $DOMAINS_DIR weblogic weblogic1 8001 $DEFAULT_MS_NAME 8011 dev $NUMBER_OF_MS
57+
./provision-domain-for-msi.sh $DOMAIN_NAME $ORACLE_HOME/wlserver/common/templates/wls/wls.jar $DOMAINS_DIR weblogic weblogic1 8001 $DEFAULT_MS_NAME $MS_PORT $PROD_OR_DEV $NUMBER_OF_MS $MS_NAME_PREFIX
5058

51-
EXPOSE 8011
59+
EXPOSE $MS_PORT
5260
WORKDIR $DOMAINS_DIR/$DOMAIN_NAME
5361
ENTRYPOINT ["/u01/oracle/launcher.sh"]

OracleWebLogic/samples/12212-msiserver/Dockerfile.addapp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ COPY ${source} /u01/apps/${simple_filename}
4646
# WLST offline use to update domain configuration
4747
# ---------------------------------------------
4848
RUN . $ORACLE_HOME/wlserver/server/bin/setWLSEnv.sh && \
49-
java weblogic.WLST /u01/oracle/add-app-to-domain.py $ORACLE_HOME/wlserver/samples/domains/msi-sample $NUMBER_OF_MS $name /u01/apps/${simple_filename}
49+
java weblogic.WLST /u01/oracle/add-app-to-domain.py $DOMAINS_DIR/$DOMAIN_NAME $NUMBER_OF_MS $name /u01/apps/${simple_filename} $MS_NAME_PREFIX

OracleWebLogic/samples/12212-msiserver/README.md

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ Example of docker images with WebLogic server in MSI Mode
22
=========================================================
33
This Dockerfile extends the Oracle WebLogic image by creating a domain that configures a managed
44
server in MSI mode (or Managed Server Independence mode). In this mode, a managed server can run
5-
without the need of an admin server
5+
without the need of an admin server. Such a managed server is not driven by admin server for
6+
configuration or deployment changes. However, it can handle all configuration and deploymnets
7+
already in config.xml like any other managed server. For use cases where the managed server does
8+
not need to be updated for configuration or deployments, this image can be used by itself without
9+
running a admin server or node manager
610

711
How to build and run the base image
812
-----------------------------------
@@ -36,15 +40,32 @@ deployed to it yet. When additional images are created by adding application(s)
3640
the same command (as above) may be used to launch the server and accessed using the URL
3741
http://localhost:8011/<relevant-context-root>
3842

39-
Randomly generated managed server name can both be overridden using environment variable.
40-
For example, the following command may be used to run a managed server with name ms1
43+
Randomly generated managed server name can be overridden using build arguments or runtime variables.
44+
45+
**Build Argument ms_name_prefix**
46+
This argument may be used to alter the prefix of managed server name, and a random
47+
number prefix is appended to it. For example, the following command may be used to
48+
run a managed with a name managedServer<RandomNumber>
4149

42-
docker run --name msiserver --env MS_NAME=ms1 12212-msiserver
50+
docker build -t 12212-msiserver --build-arg ms_name_prefix=managedServer .
4351

52+
**Build Argument number_of_ms**
4453
By default, this image comes configured with 10 managed servers, ms1 to ms10. However, the image
4554
can be built with configurable number of managed servers using NUMBER_OF_MS argument
4655

47-
docker build -t 12212-msiserver --build-arg NUMBER_OF_MS=15 .
56+
docker build -t 12212-msiserver --build-arg number_of_ms=15 .
57+
58+
**Other build arguments**
59+
* domain_name may be used to identify the name of generated domain that gets packed into MSI image. Default value msi-sample
60+
* domains_dir may be used identify the directory under $ORACLE_HOME where the domain home directory is created. Default value wlserver/samples/domains
61+
* ms_port may be used to configure port of the managed server, default is 8011
62+
* prod_or_dev may be used to identify whether server is started in production or development mode. Defaults to "dev" for development mode.
63+
64+
**Runtime Argument MS_NAME**
65+
This argument may be used to completely override the managed server name.
66+
For example, the following command may be used to run a managed server with name ms1
67+
68+
docker run --name msiserver --env MS_NAME=managedServer1 12212-msiserver
4869

4970
How to use the base image to add application
5071
--------------------------------------------
@@ -63,6 +84,12 @@ summercamps app will now be accessible at
6384
http://localhost:8011/
6485

6586
As with the base image, you can still override managed server name and cluster name
87+
**Build arguments**
88+
Three build arguments may be used to customize the image to include an application of user
89+
choice. By default, the build arguments point to an example application included in this
90+
sample. The "name" argument helps identify the name of deployment, while the "source"
91+
argument helps identify the source of the application. The source is copied into the image.
92+
So "simple_filename" helps identify the name of the file where the source is copied to
6693

6794
Using swarm service creation with this image
6895
--------------------------------------------

OracleWebLogic/samples/12212-msiserver/container-scripts/add-app-to-domain.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
number_of_ms = int(sys.argv[2])
33
app_name = sys.argv[3]
44
app_location = sys.argv[4]
5+
ms_name_prefix = sys.argv[5]
56

67
print('domain_path : [%s]' % domain_path);
78
print('app_name : [%s]' % app_name);
89
print('app_location : [%s]' % app_location);
910
print('number_of_ms : [%s]' % number_of_ms);
11+
print('ms_name_prefix : [%s]' % ms_name_prefix);
1012

1113
# Open default domain template
1214
# ======================
@@ -19,9 +21,9 @@
1921
cd('/AppDeployments/%s/' % app_name)
2022
set('StagingMode', 'nostage')
2123
set('SourcePath', app_location)
22-
targets = 'ms1'
24+
targets = ms_name_prefix + str(1)
2325
for index in range(2, number_of_ms + 1):
24-
targets = targets + ',ms%s' % index
26+
targets = targets + ',%s' % (ms_name_prefix + str(index))
2527
set('Target', targets)
2628

2729
# Write Domain

OracleWebLogic/samples/12212-msiserver/container-scripts/launcher.sh

100644100755
Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
ms_name_from_image=${DEFAULT_MS_NAME}
44
number_of_ms=${NUMBER_OF_MS}
5-
ms_name=${MS_NAME:-ms$(( ( RANDOM % $number_of_ms ) + 1 ))}
5+
ms_name=${MS_NAME:-${MS_NAME_PREFIX}$(( ( RANDOM % $number_of_ms ) + 1 ))}
66
domain_home=${DOMAINS_DIR}/${DOMAIN_NAME}
77

88
echo "Launching with parameters"
@@ -19,17 +19,19 @@ if [ "$ms_name_from_image" != "$ms_name" ]; then
1919
mv servers/$ms_name_from_image servers/$ms_name
2020
fi
2121

22+
bin/startManagedWebLogic.sh $ms_name
23+
2224
# Relays SIGTERM to all java processes
23-
function relay_SIGTERM {
24-
pid=`grep java /proc/[0-9]*/comm | awk -F / '{ print $3; }'`
25-
echo "Sending SIGTERM to java process " $pid
26-
kill -SIGTERM $pid
27-
}
28-
29-
trap relay_SIGTERM SIGTERM
30-
31-
bin/startManagedWebLogic.sh $ms_name &
32-
while true
33-
do
34-
tail -f /dev/null & wait ${!}
35-
done
25+
# function relay_SIGTERM {
26+
# pid=`grep java /proc/[0-9]*/comm | awk -F / '{ print $3; }'`
27+
# echo "Sending SIGTERM to java process " $pid
28+
# kill -SIGTERM $pid
29+
#}
30+
31+
#trap relay_SIGTERM SIGTERM
32+
33+
# bin/startManagedWebLogic.sh $ms_name &
34+
# while true
35+
# do
36+
# tail -f /dev/null & wait ${!}
37+
# done

OracleWebLogic/samples/12212-msiserver/container-scripts/provision-domain-for-msi.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,19 @@
1010
ms_port = int(sys.argv[8])
1111
production_mode = sys.argv[9]
1212
number_of_ms = int(sys.argv[10])
13+
ms_name_prefix = sys.argv[11]
1314

1415
print('domain_name : [%s]' % domain_name);
1516
print('template_location : [%s]' % template_location);
1617
print('domain_path : [%s]' % domain_path);
1718
print('user_name : [%s]' % user_name);
1819
print('password : ********');
1920
print('as_port : [%s]' % as_port);
20-
print('ms_name : [%s]' % ms_name);
21+
print('ms_name : [%s]' % ms_name);
2122
print('ms_port : [%s]' % ms_port);
2223
print('production_mode : [%s]' % production_mode);
2324
print('number_of_ms : [%s]' % number_of_ms);
25+
print('ms_name_prefix : [%s]' % ms_name_prefix);
2426

2527
# Open default domain template
2628
# ======================
@@ -57,8 +59,8 @@
5759
cd('/')
5860
sys.stdout.write('.')
5961
sys.stdout.flush()
60-
create('ms%s' % index, 'Server')
61-
cd('/Servers/ms%s/' % index )
62+
create(ms_name_prefix + str(index), 'Server')
63+
cd('/Servers/%s/' % (ms_name_prefix + str(index) ))
6264
set('ListenPort', ms_port)
6365
set('NumOfRetriesBeforeMSIMode', 0)
6466
set('RetryIntervalBeforeMSIMode', 1)

0 commit comments

Comments
 (0)