diff --git a/samples/docker-domain/Dockerfile b/samples/docker-domain/Dockerfile new file mode 100644 index 0000000000..6501328819 --- /dev/null +++ b/samples/docker-domain/Dockerfile @@ -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 + +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"] diff --git a/samples/docker-domain/README.md b/samples/docker-domain/README.md new file mode 100644 index 0000000000..aa9e91bcb4 --- /dev/null +++ b/samples/docker-domain/README.md @@ -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= -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= -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. diff --git a/samples/docker-domain/build-archive.sh b/samples/docker-domain/build-archive.sh new file mode 100755 index 0000000000..88983151bf --- /dev/null +++ b/samples/docker-domain/build-archive.sh @@ -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 * diff --git a/samples/docker-domain/build.sh b/samples/docker-domain/build.sh new file mode 100755 index 0000000000..1bee5bf978 --- /dev/null +++ b/samples/docker-domain/build.sh @@ -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 \ + --build-arg WDT_MODEL=simple-topology.yaml \ + --build-arg WDT_ARCHIVE=archive.zip \ + -t 12213-domain-wdt . + diff --git a/samples/docker-domain/container-scripts/domain.properties b/samples/docker-domain/container-scripts/domain.properties new file mode 100644 index 0000000000..3bb3ba820b --- /dev/null +++ b/samples/docker-domain/container-scripts/domain.properties @@ -0,0 +1,4 @@ +DOMAIN_NAME=my_domain +ADMIN_PORT=7001 +ADMIN_HOST=wlsadmin +ADMIN_USER=weblogic diff --git a/samples/docker-domain/container-scripts/startManagedServer.sh b/samples/docker-domain/container-scripts/startManagedServer.sh new file mode 100644 index 0000000000..bb4a7c4e31 --- /dev/null +++ b/samples/docker-domain/container-scripts/startManagedServer.sh @@ -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 diff --git a/samples/docker-domain/container-scripts/startWLSDomain.sh b/samples/docker-domain/container-scripts/startWLSDomain.sh new file mode 100644 index 0000000000..660f04a101 --- /dev/null +++ b/samples/docker-domain/container-scripts/startWLSDomain.sh @@ -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 +tail -f ${DOMAIN_HOME}/servers/AdminServer/logs/AdminServer.log & + +childPID=$! +wait $childPID diff --git a/samples/docker-domain/simple-app/WEB-INF/web.xml b/samples/docker-domain/simple-app/WEB-INF/web.xml new file mode 100644 index 0000000000..478af62e68 --- /dev/null +++ b/samples/docker-domain/simple-app/WEB-INF/web.xml @@ -0,0 +1,8 @@ + + + + /simple.html + + diff --git a/samples/docker-domain/simple-app/WEB-INF/weblogic.xml b/samples/docker-domain/simple-app/WEB-INF/weblogic.xml new file mode 100644 index 0000000000..93e03f08a1 --- /dev/null +++ b/samples/docker-domain/simple-app/WEB-INF/weblogic.xml @@ -0,0 +1,5 @@ + + + + /simple + diff --git a/samples/docker-domain/simple-app/simple.html b/samples/docker-domain/simple-app/simple.html new file mode 100644 index 0000000000..778774ec74 --- /dev/null +++ b/samples/docker-domain/simple-app/simple.html @@ -0,0 +1,9 @@ + + + Simple Application + + +

Simple Application

+

This is the simple application.

+ + diff --git a/samples/docker-domain/simple-topology.yaml b/samples/docker-domain/simple-topology.yaml new file mode 100644 index 0000000000..5b6bef2320 --- /dev/null +++ b/samples/docker-domain/simple-topology.yaml @@ -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 diff --git a/samples/docker-domain/weblogic-deploy.zip.download b/samples/docker-domain/weblogic-deploy.zip.download new file mode 100644 index 0000000000..4ea8dd5f2f --- /dev/null +++ b/samples/docker-domain/weblogic-deploy.zip.download @@ -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