Skip to content

Commit cd8d38c

Browse files
fix up topology
1 parent ec52a79 commit cd8d38c

File tree

9 files changed

+158
-135
lines changed

9 files changed

+158
-135
lines changed

samples/docker-domain/Dockerfile

Lines changed: 69 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@
1919
# $ sudo docker build \
2020
# --build-arg WDT_MODEL=simple-topology.yaml \
2121
# --build-arg WDT_ARCHIVE=archive.zip \
22+
# --build-arg WDT_VARIABLE=simple-topology.properties \
2223
# --force-rm=true \
2324
# -t 12213-domain-wdt .
2425
#
2526
# Pull base image
2627
# ---------------
2728
# FROM store/oracle/weblogic:12.2.1.3
28-
FROM oracle/weblogic:12.2.1.3-developer
29+
FROM store/oracle/weblogic:12.2.1.3-dev
2930

3031
# Maintainer
3132
# ----------
@@ -35,75 +36,96 @@ ARG WDT_MODEL
3536
ARG WDT_ARCHIVE
3637
ARG WDT_VARIABLE
3738

38-
# WLS Configuration
39+
# WLS Configuration - oracle home and domain home
40+
# The boot.properties will be created under the DOMAIN_HOME when the AdminServer container is run
3941
# ---------------------------
4042
ENV ORACLE_HOME=/u01/oracle \
4143
PROPERTIES_FILE_DIR="${ORACLE_HOME}/properties" \
42-
SCRIPT_FILE=${ORACLE_HOME}/createAndStartWLSDomain.sh \
4344
DOMAIN_HOME_PARENT=${ORACLE_HOME}/user_projects/domains \
44-
DOMAIN_HOME="${DOMAIN_HOME_PARENT}/${DOMAIN_NAME}-base_domain}" \
45-
PATH=$PATH:${ORACLE_HOME}/oracle_common/common/bin:${ORACLE_HOME}/wlserver/common/bin:${DOMAIN_HOME}/bin:${ORACLE_HOME}
46-
45+
PATH=$PATH:${ORACLE_HOME}/oracle_common/common/bin:${ORACLE_HOME}/wlserver/common/bin:${ORACLE_HOME}
46+
4747
# WDT install and WDT user files
48-
# COPY
4948
# ------------------------------------------------------------
50-
ENV COPY_PROPERTIES="poperties/docker_build" \
51-
INSTALL_HOME="/u01" \
49+
ENV COPY_PROPERTIES="properties/docker_build" \
50+
WDT_HOME="/u01" \
51+
SCRIPT_HOME="${ORACLE_HOME}" \
5252
WDT_MODEL="$WDT_MODEL" \
5353
WDT_ARCHIVE="$WDT_ARCHIVE" \
54-
WDT_VARIABLE="WDT_VARIABLE"
54+
WDT_VARIABLE="$WDT_VARIABLE"
5555

56-
# Add files required to build this image
57-
COPY container-scripts/* ${INSTALL_HOME}
58-
COPY weblogic-deploy.zip ${INSTALL_HOME}
56+
# Add files required to build this image and run a container from the image
57+
COPY container-scripts/* ${SCRIPT_HOME}/
58+
COPY weblogic-deploy.zip ${WDT_HOME}
5959

60+
# Create the properties file directory and the domain home parent with the correct permissions / owner.
61+
# Unzip and install the WDT image.
62+
# Export variable file values into the environment
6063
USER root
61-
RUN chmod +xw ${INSTALL_HOME}/*.sh && \
62-
mkdir +xwr ${PROPERTIES_FILE_DIR} && \
63-
chown -R oracle:oracle ${PROPERTIES_FILE_DIR} && \
64+
RUN chmod +xw ${SCRIPT_HOME}/*.sh && \
65+
mkdir -p +xwr ${PROPERTIES_FILE_DIR} && \
6466
mkdir -p $DOMAIN_HOME_PARENT && \
65-
chown -R oracle:oracle $DOMAIN_HOME_PARENT && \
66-
chmod -R a+xwr $DOMAIN_HOME_PARENT
67+
chmod -R a+xwr $DOMAIN_HOME_PARENT && \
68+
cd ${WDT_HOME} && \
69+
$JAVA_HOME/bin/jar xf ./weblogic-deploy.zip && \
70+
rm weblogic-deploy.zip && \
71+
chmod +xw weblogic-deploy/bin/*.sh && \
72+
chmod -R +xw weblogic-deploy/lib/python
6773

68-
COPY ${WDT_MODEL} ${WDT_ARCHIVE} ${WDT_VARIABLE} ${COPY_PROPERTIES}/*.properties ${PROPERTIES_FILE_DIR}/
74+
# Copy the WDT model, archive file, variable file and credential secrets to the property file directory.
75+
# These files will be removed after the image is built.
76+
# Be sure to build with --force-rm to eliminate this container layer
6977

70-
# export domain and server specific variables into environment
71-
RUN /bin/sh ${INSTALL_HOME}/setEnv.sh
78+
COPY ${WDT_MODEL} ${WDT_ARCHIVE} ${WDT_VARIABLE} ${COPY_PROPERTIES}/*.properties ${PROPERTIES_FILE_DIR}/
79+
80+
# Create the domain home in the docker image.
81+
#
82+
# The create domain tool creates a domain at the DOMAIN_HOME location
83+
# The domain name is set using the value in the model / variable files
84+
# The domain name can be different from the DOMAIN_HOME domain folder name.
7285

73-
# Default values - these values will be replaced by the values in the properties file
74-
# The DOMAIN_NAME in the variable file can be different than the DOMAIN NAME in the DOMAIN_HOME
75-
ENV DOMAIN_NAME="${DOMAIN_NAME:-base-domain}" \
76-
ADMIN_HOST="${ADMIN_HOST:-wlsadmin}" \
77-
ADMIN_PORT="${ADMIN_PORT:-7001}" \
78-
MS_PORT="${MS_PORT:-8001}" \
79-
DEBUG_PORT="${DEBUG_PORT:-8453}" \
80-
DOMAIN_HOME="${DOMAIN_PARENT}\${DOMAIN
81-
PATH=${PATH}:
86+
ENV WDT_HOME=$WDT_HOME/weblogic-deploy
8287

83-
# Run the WDT createDomain to create the domain home in the image
84-
RUN cd ${INSTALL_HOME} && \
85-
$JAVA_HOME/bin/jar xf ${INSTALL_HOME_BASE}/weblogic-deploy.zip && \
86-
chmod +xw ${INSTALL_HOME_BASE}/weblogic-deploy/bin/*.sh && \
87-
chmod -R +xw ${INSTALL_HOME_BASE}/weblogic-deploy/lib/python && \
88-
if [ -n "$WDT_MODEL" ]; then MODEL_OPT="-archive_file ${INSTALL_HOME_BASE}/$WDT_ARCHIVE"; fi && \
89-
if [ -n "$WDT_ARCHIVE" ]; then ARCHIVE_OPT="-archive_file ${INSTALL_HOME_BASE}/$WDT_ARCHIVE"; fi && \
90-
if [ -n "$WDT_VARIABLE" ]; then VARIABLE_OPT="-variable_file ${INSTALL_HOME_BASE}/$WDT_VARIABLE"; fi && \
91-
/u01/weblogic-deploy/bin/createDomain.sh \
92-
-oracle_home $ORACLE_HOME \
88+
# Set WORKDIR for @@PWD@@ global token in model file
89+
WORKDIR $ORACLE_HOME
90+
RUN chmod -R +xwr ${PROPERTIES_FILE_DIR} && \
91+
PROPERTIES_FILE=$PROPERTIES_FILE_DIR/$WDT_VARIABLE && \
92+
. ${SCRIPT_HOME}/setEnv.sh && \
93+
DOMAIN_HOME=${DOMAIN_HOME_PARENT}/${DOMAIN_NAME} && \
94+
export DOMAIN_HOME && \
95+
if [ -n "$WDT_MODEL" ]; then MODEL_OPT="-model_file $PROPERTIES_FILE_DIR/$WDT_MODEL"; fi && \
96+
if [ -n "$WDT_ARCHIVE" ]; then ARCHIVE_OPT="-archive_file $PROPERTIES_FILE_DIR/$WDT_ARCHIVE"; fi && \
97+
if [ -n "$WDT_VARIABLE" ]; then VARIABLE_OPT="-variable_file $PROPERTIES_FILE"; fi && \
98+
${WDT_HOME}/bin/createDomain.sh \
99+
-oracle_home ${ORACLE_HOME} \
93100
-java_home ${JAVA_HOME} \
94101
-domain_home ${DOMAIN_HOME} \
95102
-domain_type WLS \
96-
$VARIABLE_OPT \
103+
$VARIABLE_OPT \
97104
$MODEL_OPT \
98105
$ARCHIVE_OPT && \
99-
rm ${PROPERTIES_FILE_DIR}/*
106+
chown -R oracle:oracle ${DOMAIN_HOME_PARENT} && \
107+
rm -rf ${PROPERTIES_FILE_DIR}
100108

101-
VOLUME $PRE_DOMAIN_HOME
102-
# Expose Node Manager default port, and also default for admin and managed server
109+
# Set the ENV variables needed for runing container.
110+
# If these variables are not in the variable file and not set on the build or run, set a default value.
111+
# If not using a variable file, then make sure these ENV values match those in the model.
112+
ENV ADMIN_HOST="${ADMIN_HOST:-wlsadmin}" \
113+
ADMIN_PORT="${ADMIN_PORT:-7001}" \
114+
MS_NAME="${MS_NAME}" \
115+
MS_PORT="${MS_PORT:-8001}" \
116+
DEBUG_PORT="${DEBUG_PORT:-8453}" \
117+
DOMAIN_NAME="`awk '{print $1}' $PROPERTIES_FILE | grep ^DOMAIN_NAME= | cut -d "=" -f2`" \
118+
DOMAIN_HOME="$DOMAIN_HOME_PARENT/$DOMAIN_NAME" \
119+
WDT_HOME="${WDT_HOME}/weblogic-deploy" \
120+
PATH=$PATH:$DOMAIN_HOME/bin
121+
122+
VOLUME $DOMAIN_HOME
123+
124+
# Expose admin server, managed server port and domain debug port
103125
EXPOSE $ADMIN_PORT $MS_PORT $DEBUG_PORT
104126

127+
# Define default command to start bash.
128+
WORKDIR $SCRIPT_HOME
105129
USER oracle
106-
WORKDIR $ORACLE_HOME
107130

108-
# Define default command to start bash.
109-
CMD ["${ORACLE_HOME}/startWLSDomain.sh"]
131+
CMD ["./startWLSDomain.sh"]

samples/docker-domain/README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ 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 file includes variable tokens that are replaced with values from the provided 'simple-topology.properties'. The properties files can be created and modified using a text editor. The property file must contain the values that the Dockerfile sets as ENV variables to expose ports
16+
and run a server in a docker container.
17+
18+
The admin server credentials in the sample model contain file tokens that reference special property files. A special property file must contain only one property value pair. The sample includes the credentials secrets property files in the properties/docker_build directory. The files can be created and modified using a text editor; one file must contain the admin password and one file must contain the admin user. See the README file for more information on using property and file tokens in the WDT model.
19+
1520
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.
1621

1722
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.
@@ -33,22 +38,25 @@ To build this sample, run:
3338
$ docker build \
3439
--build-arg WDT_MODEL=simple-topology.yaml \
3540
--build-arg WDT_ARCHIVE=archive.zip \
41+
--build-arg WDT_VARIABLE=simple-topology.properties \
3642
--force-rm=true \
3743
-t 12213-domain-wdt .
3844

39-
This will use the model file and archive in the sample directory.
45+
This will use the model, variable and archive files in the sample directory.
46+
47+
The Admin Server and each Managed Server are run in containers from this build image. The admin server credentials, required for running the admin server or a managed server, are provided in a properties file. This sample contains a credentials properties file in the properties/docker_run directory, which can be mounted into a volume on the container image. It is the responsibility of the user to mange the properties file in this mounted container volume.
4048

4149
To start the containerized Administration Server, run:
4250

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

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

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

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

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

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

samples/docker-domain/build.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#
77
docker build \
88
--build-arg WDT_MODEL=simple-topology.yaml \
9+
--build-arg WDT_VARIABLE=simple-topology.properties \
910
--build-arg WDT_ARCHIVE=archive.zip \
10-
-t 12213-domain-wdt .
11+
-t 12213-domain-wdt-test .
1112

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

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,51 @@
33
# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
44
# The Universal Permissive License (UPL), Version 1.0
55
#
6-
# Set the Domain environment variables.
6+
# if [ $# > 0 ]; then
7+
# PROPERTIES_FILE=$1
8+
# fi
79

8-
if [ ! -e "$WDT_VARIABLE" ]; then
10+
if [ ! -e "${PROPERTIES_FILE}" ]; then
911
echo "A properties file with variable definitions should be supplied."
10-
goto envexit
12+
exit 1
1113
fi
1214

13-
DOMAIN_NAME=`awk '{print $1}' $WDT_VARIABLE | grep ^DOMAIN_NAME= | cut -d "=" -f2`
14-
if [ -n "$DOMAIN_NAME" ]; then
15-
export DOMAIN_NAME
15+
echo Export environment variables from the ${PROPERTIES_FILE} properties file
16+
17+
DOMAIN_DIR=`awk '{print $1}' $PROPERTIES_FILE | grep ^DOMAIN_NAME= | cut -d "=" -f2`
18+
if [ ! -n "$DOMAIN_DIR" ]; then
19+
if [ -n "$DOMAIN_NAME" ]; then
20+
DOMAIN_DIR=$DOMAIN_NAME
21+
else
22+
DOMAIN_DIR=base_domain
23+
fi
1624
fi
25+
DOMAIN_NAME=$DOMAIN_DIR
26+
export DOMAIN_NAME
27+
echo DOMAIN_NAME=$DOMAIN_NAME
1728

18-
ADMIN_HOST=`awk '{print $1}' $WDT_VARIABLE | grep ^ADMIN_HOST= | cut -d "=" -f2`
29+
ADMIN_HOST=`awk '{print $1}' $PROPERTIES_FILE | grep ^ADMIN_HOST= | cut -d "=" -f2`
1930
if [ -n "$ADMIN_HOST" ]; then
2031
export ADMIN_HOST
32+
echo ADMIN_HOST=$ADMIN_HOST
2133
fi
2234

23-
ADMIN_PORT=`awk '{print $1}' $WDT_VARIABLE | grep ^ADMIN_PORT= | cut -d "=" -f2`
35+
ADMIN_PORT=`awk '{print $1}' $PROPERTIES_FILE | grep ^ADMIN_PORT= | cut -d "=" -f2`
2436
if [ -n "$ADMIN_PORT" ]; then
2537
export ADMIN_PORT
38+
echo ADMIN_PORT=$ADMIN_PORT
2639
fi
2740

28-
MS_PORT=`awk '{print $1}' $WDT_VARIABLE | grep ^MS_PORT= | cut -d "=" -f2`
41+
MS_PORT=`awk '{print $1}' $PROPERTIES_FILE | grep ^MS_PORT= | cut -d "=" -f2`
2942
if [ -n "$MS_PORT" ]; then
3043
export MS_PORT
44+
echo MS_PORT=$MS_PORT
3145
fi
3246

33-
DEBUG_PORT=`awk '{print $1}' $WDT_VARIABLE | grep ^MS_PORT= | cut -d "=" -f2`
47+
DEBUG_PORT=`awk '{print $1}' $PROPERTIES_FILE | grep ^MS_PORT= | cut -d "=" -f2`
3448
if [ -n "$DEBUG_PORT" ]; then
3549
export DEBUG_PORT
50+
echo DEBUG_PORT=$DEBUG_PORT
3651
fi
3752

38-
envexit:
53+

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

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,12 @@
66
#
77
# Start the Domain.
88

9-
PROPERTIES_FILE=/u01/oracle/properties/domain.properties
9+
PROPERTIES_FILE=/u01/oracle/properties/security.properties
1010
if [ ! -e "$PROPERTIES_FILE" ]; then
1111
echo "A 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."
18-
exit
19-
fi
20-
2115
USER=`awk '{print $1}' $PROPERTIES_FILE | grep ^username= | cut -d "=" -f2`
2216
if [ -z "$USER" ]; then
2317
echo "The admin username is blank. The admin username must be set in the properties file."
@@ -30,21 +24,6 @@ if [ -z "$PASS" ]; then
3024
exit
3125
fi
3226

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
47-
4827
mkdir -p $DOMAIN_HOME/servers/$MS_NAME/security
4928
echo username=$USER > $DOMAIN_HOME/servers/$MS_NAME/security/boot.properties
5029
echo password=$PASS >> $DOMAIN_HOME/servers/$MS_NAME/security/boot.properties

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

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,12 @@
66
#
77
# Start the Domain.
88

9-
PROPERTIES_FILE=/u01/oracle/properties/domain.properties
9+
PROPERTIES_FILE=/u01/oracle/properties/security.properties
1010
if [ ! -e "$PROPERTIES_FILE" ]; then
1111
echo "A properties file with the username and password 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."
18-
exit
19-
fi
20-
2115
USER=`awk '{print $1}' $PROPERTIES_FILE | grep ^username= | cut -d "=" -f2`
2216
if [ -z "$USER" ]; then
2317
echo "The domain username is blank. The Admin username must be set in the properties file."
@@ -30,9 +24,6 @@ if [ -z "$PASS" ]; then
3024
exit
3125
fi
3226

33-
#Define DOMAIN_HOME
34-
export DOMAIN_HOME=/u01/oracle/user_projects/domains/$DOMAIN_NAME
35-
3627
mkdir -p ${DOMAIN_HOME}/servers/AdminServer/security/
3728
echo "username=${USER}" >> $DOMAIN_HOME/servers/AdminServer/security/boot.properties
3829
echo "password=${PASS}" >> $DOMAIN_HOME/servers/AdminServer/security/boot.properties
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
ADMIN_USER=weblogic
2-
ADMIN_PASS=welcome1
3-
DOMAIN_NAME=my_domain
1+
username=weblogic
2+
password=welcome1

0 commit comments

Comments
 (0)