Skip to content

Commit 05944bb

Browse files
authored
Merge pull request #131 from oracle/issue#130-add-docker-sample-that-creates-a-domain
Issue#130 add docker sample that creates a domain
2 parents 1ff34b2 + 6ba3a70 commit 05944bb

File tree

12 files changed

+319
-0
lines changed

12 files changed

+319
-0
lines changed

samples/docker-domain/Dockerfile

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#Copyright (c) 2014-2018 Oracle and/or its affiliates. All rights reserved.
2+
#
3+
#Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
4+
#
5+
# ORACLE DOCKERFILES PROJECT
6+
# --------------------------
7+
# This Dockerfile extends the Oracle WebLogic image by creating a sample domain.
8+
#
9+
# Util scripts are copied into the image enabling users to plug NodeManager
10+
# automatically into the AdminServer running on another container.
11+
#
12+
# HOW TO BUILD THIS IMAGE
13+
# -----------------------
14+
# Put all downloaded files in the same directory as this Dockerfile
15+
# Build the deployment archive file using the build-archive.sh script.
16+
# $ ./build-archive.sh
17+
#
18+
# Run:
19+
# $ sudo docker build \
20+
# --build-arg WDT_MODEL=simple-topology.yaml \
21+
# --build-arg WDT_ARCHIVE=archive.zip \
22+
# -t 12213-domain-wdt .
23+
#
24+
# Pull base image
25+
# ---------------
26+
FROM store/oracle/weblogic:12.2.1.3
27+
28+
# Maintainer
29+
# ----------
30+
MAINTAINER Monica Riccelli <[email protected]>
31+
32+
ARG WDT_MODEL
33+
ARG WDT_ARCHIVE
34+
35+
# WLS Configuration
36+
# ---------------------------
37+
ENV ADMIN_HOST="wlsadmin" \
38+
NM_PORT="5556" \
39+
MS_PORT="8001" \
40+
DEBUG_PORT="8453" \
41+
ORACLE_HOME=/u01/oracle \
42+
SCRIPT_FILE=/u01/oracle/createAndStartWLSDomain.sh \
43+
CONFIG_JVM_ARGS="-Dweblogic.security.SSL.ignoreHostnameVerification=true" \
44+
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
45+
46+
# Domain and Server environment variables
47+
# ------------------------------------------------------------
48+
ENV DOMAIN_NAME="${DOMAIN_NAME:-base_domain}" \
49+
PRE_DOMAIN_HOME=/u01/oracle/user_projects \
50+
ADMIN_PORT="${ADMIN_PORT:-7001}" \
51+
WDT_MODEL="$WDT_MODEL" \
52+
WDT_ARCHIVE="$WDT_ARCHIVE"
53+
54+
# Add files required to build this image
55+
COPY container-scripts/* /u01/oracle/
56+
COPY weblogic-deploy.zip /u01
57+
COPY ${WDT_MODEL} ${ARCHIVE_FILE} /u01/
58+
59+
#Create directory where domain will be written to
60+
USER root
61+
RUN chmod +xw /u01/oracle/*.sh && \
62+
chmod +xw /u01/oracle/*.py && \
63+
mkdir -p $PRE_DOMAIN_HOME && \
64+
mkdir -p $PRE_DOMAIN_HOME/domains && \
65+
chmod a+xr $PRE_DOMAIN_HOME && \
66+
chown -R oracle:oracle $PRE_DOMAIN_HOME && \
67+
cd /u01 && \
68+
$JAVA_HOME/bin/jar xf /u01/weblogic-deploy.zip && \
69+
chmod +xw /u01/weblogic-deploy/bin/*.sh && \
70+
chmod -R +xw /u01/weblogic-deploy/lib/python && \
71+
if [ -n "$WDT_MODEL" ]; then MODEL_OPT="-model_file /u01/$WDT_MODEL"; fi && \
72+
if [ -n "$WDT_ARCHIVE" ]; then ARCHIVE_OPT="-archive_file /u01/$WDT_ARCHIVE"; fi && \
73+
/u01/weblogic-deploy/bin/createDomain.sh \
74+
-oracle_home $ORACLE_HOME \
75+
-java_home ${JAVA_HOME} \
76+
-domain_parent $PRE_DOMAIN_HOME/domains \
77+
-domain_type WLS \
78+
-variable_file /u01/oracle/domain.properties \
79+
$MODEL_OPT \
80+
$ARCHIVE_OPT && \
81+
chown -R oracle:oracle $PRE_DOMAIN_HOME
82+
83+
VOLUME $PRE_DOMAIN_HOME
84+
# Expose Node Manager default port, and also default for admin and managed server
85+
EXPOSE $NM_PORT $ADMIN_PORT $MS_PORT $DEBUG_PORT
86+
87+
USER oracle
88+
WORKDIR $ORACLE_HOME
89+
90+
# Define default command to start bash.
91+
CMD ["/u01/oracle/startWLSDomain.sh"]

samples/docker-domain/README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
Example Image with a WLS Domain
2+
===============================
3+
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.
4+
5+
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:
6+
7+
https://github.com/oracle/weblogic-deploy-tooling
8+
9+
### WDT Model File and Archive
10+
11+
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.
12+
13+
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.
14+
15+
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.
16+
17+
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.
18+
19+
### How to Build and Run
20+
21+
**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.
22+
23+
The WebLogic Deploy Tool installer is required to build this image. Add weblogic-deploy.zip to the sample directory.
24+
25+
$ wget https://github.com/oracle/weblogic-deploy-tooling/releases/download/weblogic-deploy-tooling-0.11/weblogic-deploy.zip
26+
27+
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.
28+
29+
$ ./build-archive.sh
30+
31+
To build this sample, run:
32+
33+
$ docker build \
34+
--build-arg WDT_MODEL=simple-topology.yaml \
35+
--build-arg WDT_ARCHIVE=archive.zip \
36+
-t 12213-domain-wdt .
37+
38+
This will use the model file and archive in the sample directory.
39+
40+
To start the containerized Administration Server, run:
41+
42+
$ docker run -d --name wlsadmin --hostname wlsadmin -p 7001:7001 --env-file ./container-scripts/domain.properties 12213-domain-wdt
43+
44+
To start a containerized Managed Server (ms-1) to self-register with the Administration Server above, run:
45+
46+
$ 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
47+
48+
To start an additional Managed Server (in this example ms-2), run:
49+
50+
$ 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
51+
52+
The above scenario from this sample will give you a WebLogic domain with a dynamic cluster set up on a single host environment.
53+
54+
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`.
55+
56+
# Copyright
57+
Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh
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+
rm -Rf archive
8+
mkdir -p archive/wlsdeploy/applications
9+
cd simple-app
10+
jar cvf ../archive/wlsdeploy/applications/simple-app.war *
11+
cd ../archive
12+
jar cvf ../archive.zip *

samples/docker-domain/build.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/sh
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+
docker build \
8+
--build-arg WDT_MODEL=simple-topology.yaml \
9+
--build-arg WDT_ARCHIVE=archive.zip \
10+
-t 12213-domain-wdt .
11+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
DOMAIN_NAME=my_domain
2+
ADMIN_PORT=7001
3+
ADMIN_HOST=wlsadmin
4+
ADMIN_USER=weblogic
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
#
3+
#Copyright (c) 2014-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.
8+
9+
#Define DOMAIN_HOME
10+
export DOMAIN_HOME=/u01/oracle/user_projects/domains/$DOMAIN_NAME
11+
12+
mkdir -p $DOMAIN_HOME/servers/$MS_NAME/security
13+
echo username=$ADMIN_USER > $DOMAIN_HOME/servers/$MS_NAME/security/boot.properties
14+
echo password=$ADMIN_PASSWORD >> $DOMAIN_HOME/servers/$MS_NAME/security/boot.properties
15+
16+
# Start Managed Server and tail the logs
17+
${DOMAIN_HOME}/bin/startManagedWebLogic.sh $MS_NAME http://$ADMIN_HOST:$ADMIN_PORT
18+
touch ${DOMAIN_HOME}/servers/$MS_NAME/logs/${MS_NAME}.log
19+
tail -f ${DOMAIN_HOME}/servers/$MS_NAME/logs/${MS_NAME}.log &
20+
21+
childPID=$!
22+
wait $childPID
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
#
3+
#Copyright (c) 2014-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.
8+
9+
# determine the domain name. there is only one domain directory.
10+
export DOMAIN_NAME=`ls /u01/oracle/user_projects/domains | head -1`
11+
12+
#Define DOMAIN_HOME
13+
export DOMAIN_HOME=/u01/oracle/user_projects/domains/$DOMAIN_NAME
14+
15+
# Start Admin Server and tail the logs
16+
${DOMAIN_HOME}/startWebLogic.sh
17+
touch ${DOMAIN_HOME}/servers/AdminServer/logs/AdminServer.log
18+
tail -f ${DOMAIN_HOME}/servers/AdminServer/logs/AdminServer.log &
19+
20+
childPID=$!
21+
wait $childPID
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
5+
<welcome-file-list>
6+
<welcome-file>/simple.html</welcome-file>
7+
</welcome-file-list>
8+
</web-app>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="ISO-8859-1"?>
2+
3+
<weblogic-web-app xmlns="http://www.bea.com/ns/weblogic/90">
4+
<context-root>/simple</context-root>
5+
</weblogic-web-app>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<html>
2+
<head>
3+
<title>Simple Application</title>
4+
</head>
5+
<body>
6+
<h1>Simple Application</h1>
7+
<p>This is the simple application.</p>
8+
</body>
9+
</html>

0 commit comments

Comments
 (0)