Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
9650906
Issue #130 - Add a docker sample that creates a domain from a WDT model
rakillen Jun 19, 2018
a67a8ef
corrected domain directory owner
rakillen Jun 19, 2018
ef54a92
Issue#127 - Update README.md
rakillen Jun 19, 2018
d2efccb
Issue#127 - Update WebLogic Deploy Tool download file
rakillen Jun 19, 2018
d358e00
Issue #130 - corrected archive option name
rakillen Jun 20, 2018
07dae77
Issue #130 - enable build and deploy of simple application
rakillen Jun 20, 2018
6b78d59
Merge branch 'issue#130-add-docker-sample-that-creates-a-domain' of g…
rakillen Jun 20, 2018
bf1ee34
Issue#127 - Added instructions for building the sample archive
rakillen Jun 21, 2018
527f5d2
Issue#130 - Moved samples directory to top level
rakillen Jun 21, 2018
6053557
Issue #130 - change script permissions back to executable
rakillen Jun 21, 2018
6102f25
Use environment variables in createDomain, corrected how-to
rakillen Jun 22, 2018
daafc38
Issue #130 - Updated README.md from review comments
rakillen Jun 22, 2018
63f59d5
Issue #130 - Added checksum to download file
rakillen Jun 22, 2018
4025e20
Merge remote-tracking branch 'origin/issue#130-add-docker-sample-that…
rakillen Jun 22, 2018
b815bf2
Issue #130 - Corrected domain parent value
rakillen Jun 22, 2018
648d384
Merge branch 'issue#130-add-docker-sample-that-creates-a-domain' of g…
rakillen Jun 22, 2018
ae0d841
Issue #130 - Added script to start managed server
rakillen Jun 28, 2018
ad86a0f
Issue #130 - Use dynamic cluster in model; use variables from file in…
rakillen Jun 28, 2018
7423c43
Issue #130 - Deploy application to cluster, not admin server
rakillen Jun 28, 2018
6ba3a70
Issue#130 - Updated README.md with server start information
rakillen Jun 28, 2018
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
91 changes: 91 additions & 0 deletions samples/docker-domain/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#Copyright (c) 2014-2018 Oracle and/or its affiliates. All rights reserved.
#
#Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
#
# ORACLE DOCKERFILES PROJECT
# --------------------------
# This Dockerfile extends the Oracle WebLogic image by creating a sample domain.
#
# Util scripts are copied into the image enabling users to plug NodeManager
# automatically into the AdminServer running on another container.
#
# HOW TO BUILD THIS IMAGE
# -----------------------
# Put all downloaded files in the same directory as this Dockerfile
# Build the deployment archive file using the build-archive.sh script.
# $ ./build-archive.sh
#
# Run:
# $ sudo docker build \
# --build-arg WDT_MODEL=simple-topology.yaml \
# --build-arg WDT_ARCHIVE=archive.zip \
# -t 12213-domain-wdt .
#
# Pull base image
# ---------------
FROM store/oracle/weblogic:12.2.1.3

# Maintainer
# ----------
MAINTAINER Monica Riccelli <monica.riccelli@oracle.com>

ARG WDT_MODEL
ARG WDT_ARCHIVE

# WLS Configuration
# ---------------------------
ENV ADMIN_HOST="wlsadmin" \
NM_PORT="5556" \
MS_PORT="8001" \
DEBUG_PORT="8453" \
ORACLE_HOME=/u01/oracle \
SCRIPT_FILE=/u01/oracle/createAndStartWLSDomain.sh \
CONFIG_JVM_ARGS="-Dweblogic.security.SSL.ignoreHostnameVerification=true" \
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

# Domain and Server environment variables
# ------------------------------------------------------------
ENV DOMAIN_NAME="${DOMAIN_NAME:-base_domain}" \
PRE_DOMAIN_HOME=/u01/oracle/user_projects \
ADMIN_PORT="${ADMIN_PORT:-7001}" \
WDT_MODEL="$WDT_MODEL" \
WDT_ARCHIVE="$WDT_ARCHIVE"

# Add files required to build this image
COPY container-scripts/* /u01/oracle/
COPY weblogic-deploy.zip /u01
COPY ${WDT_MODEL} ${ARCHIVE_FILE} /u01/

#Create directory where domain will be written to
USER root
RUN chmod +xw /u01/oracle/*.sh && \
chmod +xw /u01/oracle/*.py && \
mkdir -p $PRE_DOMAIN_HOME && \
mkdir -p $PRE_DOMAIN_HOME/domains && \
chmod a+xr $PRE_DOMAIN_HOME && \
chown -R oracle:oracle $PRE_DOMAIN_HOME && \
cd /u01 && \
$JAVA_HOME/bin/jar xf /u01/weblogic-deploy.zip && \
chmod +xw /u01/weblogic-deploy/bin/*.sh && \
chmod -R +xw /u01/weblogic-deploy/lib/python && \
if [ -n "$WDT_MODEL" ]; then MODEL_OPT="-model_file /u01/$WDT_MODEL"; fi && \
if [ -n "$WDT_ARCHIVE" ]; then ARCHIVE_OPT="-archive_file /u01/$WDT_ARCHIVE"; fi && \
/u01/weblogic-deploy/bin/createDomain.sh \
-oracle_home $ORACLE_HOME \
-java_home ${JAVA_HOME} \
-domain_parent $PRE_DOMAIN_HOME/domains \
-domain_type WLS \
-variable_file /u01/oracle/domain.properties \
$MODEL_OPT \
$ARCHIVE_OPT && \
chown -R oracle:oracle $PRE_DOMAIN_HOME

VOLUME $PRE_DOMAIN_HOME
# Expose Node Manager default port, and also default for admin and managed server
EXPOSE $NM_PORT $ADMIN_PORT $MS_PORT $DEBUG_PORT

USER oracle
WORKDIR $ORACLE_HOME

# Define default command to start bash.
CMD ["/u01/oracle/startWLSDomain.sh"]
57 changes: 57 additions & 0 deletions samples/docker-domain/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
Example Image with a WLS Domain
===============================
This Dockerfile extends the Oracle WebLogic image by creating a sample WLS 12.2.1.3 domain and cluster. Utility scripts are copied into the image, enabling users to plug Node Manager automatically into the Administration Server running on another container.

The Dockerfile uses the createDomain script from the Oracle WebLogic Deploy Tooling (WDT) to create the domain from a text-based model file. More information about WDT is available in the README file for the WDT project in GitHub:

https://github.com/oracle/weblogic-deploy-tooling

### WDT Model File and Archive

This sample includes a basic WDT model, simple-topology.yaml, that describes the intended configuration of the domain within the Docker image. WDT models can be created and modified using a text editor, following the format and rule described in the README file for the WDT project in GitHub.

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.

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.

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.

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

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

$ wget https://github.com/oracle/weblogic-deploy-tooling/releases/download/weblogic-deploy-tooling-0.11/weblogic-deploy.zip

This sample deploys a simple one-page web application contained in a .zip archive. This archive needs to be built (one time only) before building the Docker image.

$ ./build-archive.sh

To build this sample, run:

$ docker build \
--build-arg WDT_MODEL=simple-topology.yaml \
--build-arg WDT_ARCHIVE=archive.zip \
-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

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

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

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

You may create more containerized Managed Servers by calling the `docker` command above for `startManagedServer.sh` as long you link properly with the Administration Server. For an example of a multihost environment, see the sample `1221-multihost`.

# Copyright
Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
12 changes: 12 additions & 0 deletions samples/docker-domain/build-archive.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh
#
#Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
#
#Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
#
rm -Rf archive
mkdir -p archive/wlsdeploy/applications
cd simple-app
jar cvf ../archive/wlsdeploy/applications/simple-app.war *
cd ../archive
jar cvf ../archive.zip *
11 changes: 11 additions & 0 deletions samples/docker-domain/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
#
#Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
#
#Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
#
docker build \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, that looks pretty straightforward. Let me know if he wants to do this.

--build-arg WDT_MODEL=simple-topology.yaml \
--build-arg WDT_ARCHIVE=archive.zip \
-t 12213-domain-wdt .

4 changes: 4 additions & 0 deletions samples/docker-domain/container-scripts/domain.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
DOMAIN_NAME=my_domain
ADMIN_PORT=7001
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need this domain.properties if you have a simple-properties.yaml and can define the defaults in the Dockerfile

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't currently use this for the admin startup script, not sure if we will need for the server scripts. One problem is that we can't easily extract the values we want from the yaml model file. I'll know more once we have startup scripts.

ADMIN_HOST=wlsadmin
ADMIN_USER=weblogic
22 changes: 22 additions & 0 deletions samples/docker-domain/container-scripts/startManagedServer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
#
#Copyright (c) 2014-2018 Oracle and/or its affiliates. All rights reserved.
#
#Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
#
# Start the Domain.

#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

# Start Managed Server and tail the logs
${DOMAIN_HOME}/bin/startManagedWebLogic.sh $MS_NAME http://$ADMIN_HOST:$ADMIN_PORT
touch ${DOMAIN_HOME}/servers/$MS_NAME/logs/${MS_NAME}.log
tail -f ${DOMAIN_HOME}/servers/$MS_NAME/logs/${MS_NAME}.log &

childPID=$!
wait $childPID
21 changes: 21 additions & 0 deletions samples/docker-domain/container-scripts/startWLSDomain.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
#
#Copyright (c) 2014-2018 Oracle and/or its affiliates. All rights reserved.
#
#Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
#
# Start the Domain.

# determine the domain name. there is only one domain directory.
export DOMAIN_NAME=`ls /u01/oracle/user_projects/domains | head -1`

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

# Start Admin Server and tail the logs
${DOMAIN_HOME}/startWebLogic.sh
touch ${DOMAIN_HOME}/servers/AdminServer/logs/AdminServer.log
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should discuss this as for K8s we're going to want the logs relocated outside the domain home to a file-system location where a persistent volume is mounted.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is planned to have a dynamic cluster, still working on that. I think the log directory can be moved to persistent volume.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this statement does not preclude the logs being outside. The mechanism in Docker -v is used to map the logs outside of the container.

tail -f ${DOMAIN_HOME}/servers/AdminServer/logs/AdminServer.log &

childPID=$!
wait $childPID
8 changes: 8 additions & 0 deletions samples/docker-domain/simple-app/WEB-INF/web.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<welcome-file-list>
<welcome-file>/simple.html</welcome-file>
</welcome-file-list>
</web-app>
5 changes: 5 additions & 0 deletions samples/docker-domain/simple-app/WEB-INF/weblogic.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="ISO-8859-1"?>

<weblogic-web-app xmlns="http://www.bea.com/ns/weblogic/90">
<context-root>/simple</context-root>
</weblogic-web-app>
9 changes: 9 additions & 0 deletions samples/docker-domain/simple-app/simple.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<html>
<head>
<title>Simple Application</title>
</head>
<body>
<h1>Simple Application</h1>
<p>This is the simple application.</p>
</body>
</html>
74 changes: 74 additions & 0 deletions samples/docker-domain/simple-topology.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
domainInfo:
AdminUserName: '@@PROP:ADMIN_USER@@'
AdminPassword: welcome1
ServerStartMode: dev
topology:
Name: '@@PROP:DOMAIN_NAME@@'
AdminServerName: AdminServer
Cluster:
mycluster:
ClientCertProxyEnabled: true
ClusterMessagingMode: unicast
DynamicServers:
ServerTemplate: template1
CalculatedListenPorts: false
MaximumDynamicServerCount: 2
ServerNamePrefix: 'ms-'
DynamicClusterSize: 2
MaxDynamicClusterSize: 8
Server:
AdminServer:
Machine: machine1
ListenPort: '@@PROP:ADMIN_PORT@@'
ServerTemplate:
template1:
Machine: machine1
ListenPort: 9001
Machine:
machine1:
Notes: The only machine
NodeManager:
NMType: SSL
ListenPort: 5556
Notes: The only node manager
SecurityConfiguration:
NodeManagerUsername: weblogic
NodeManagerPasswordEncrypted: welcome1
JMX:
InvocationTimeoutSeconds: 40
Notes: JMX notes
ManagedServerNotificationsEnabled: true
JTA:
MaxTransactions: 4
Notes: JTA notes
resources:
JDBCSystemResource:
Generic1:
Target: mycluster
JdbcResource:
JDBCDataSourceParams:
JNDIName: [ jdbc/generic1, jdbc/special1 ]
GlobalTransactionsProtocol: TwoPhaseCommit
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
Properties:
user:
Value: jshum
oracle.net.CONNECT_TIMEOUT:
Value: 5000
oracle.jdbc.ReadTimeout:
Value: 30000
JDBCConnectionPoolParams:
InitialCapacity: 0
MaxCapacity: 15
appDeployments:
Application:
# Quote needed because of hyphen in string
'simple-app':
SourcePath: 'wlsdeploy/applications/simple-app.war'
Target: mycluster
ModuleType: war
StagingMode: nostage
PlanStagingMode: nostage
5 changes: 5 additions & 0 deletions samples/docker-domain/weblogic-deploy.zip.download
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Download the WebLogic Deploy Tool installer to the sample directory.
#
# - wget https://github.com/oracle/weblogic-deploy-tooling/releases/download/weblogic-deploy-tooling-0.11/weblogic-deploy.zip
#
d35e83d969dd6a485409da6e9eca250f weblogic-deploy.zip