Skip to content

Commit

Permalink
Docker - Added Drools Workbench, Drools Workbench Showcase, KIE Serve…
Browse files Browse the repository at this point in the history
…r & KIE Server Showcase images.
  • Loading branch information
romartin committed Apr 29, 2015
1 parent 6121fa9 commit 1ef7f71
Show file tree
Hide file tree
Showing 23 changed files with 2,190 additions and 0 deletions.
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Drools Workbench and KIE Server - Docker images
===============================================

JBoss Drools Workbench [Docker](http://docker.io/) images.

This module provides the community Drools Workbench and KIE Server images.

Drools Workbench
================

There are two available images:

**Drools Workbench**

It's the base Docker image for Drools Workbench. It's purpose is to be used as base for extending and creating your own images that uses Drools Workbench.

**Drools Workbench showcase**

It inherits from Drools Workbench image and provides a **ready to run Docker image for Drools Workbench**.
It provides some custom configurations and default users and roles to try and test the workbench.

KIE Server
==========

KIE Server provides an standalone Drools execution environment to execute your Drools rules.

There are two available images:

**KIE Server**

It's the base Docker image for KIE Server. It's purpose is to be used as base for extending and creating your own images that uses KIE Server runtime environment.

**KIE Server showcase**

It inherits from KIE Server Workbench image and provides a **ready to run Docker image for KIE Server**.
It provides a default users and role to try and test the KIE server.
37 changes: 37 additions & 0 deletions drools-wb/base/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
##########################################################################
# Dockerfile image that provides JBoss Drools Workbench 6.2.0.Final
#
# The web application binaries are downloaded from JBoss Nexus Repository.
#
# The Docker image generated name/tag is "jboss/drools-workbench:6.2.0"
##########################################################################

####### BASE ############
FROM jboss/wildfly:8.1.0.Final

####### MAINTAINER ############
MAINTAINER "Roger Martinez" "romartin@redhat.com"

####### ENVIRONMENT ############
ENV KIE_REPOSITORY https://repository.jboss.org/nexus/content/groups/public-jboss/
ENV DROOLS_VERSION 6.2.0.Final
ENV DROOLS_CLASSIFIER wildfly8
ENV DROOLS_CONTEXT_PATH drools-wb
ENV JAVA_OPTS -XX:MaxPermSize=256m -Xms256m -Xmx512m

####### CUSTOM JBOSS USER ############
# Switchback to jboss user
USER jboss

####### DROOLS-WB ############
RUN curl -o /opt/jboss/$DROOLS_CONTEXT_PATH.war $KIE_REPOSITORY/org/kie/kie-drools-wb-distribution-wars/$DROOLS_VERSION/kie-drools-wb-distribution-wars-$DROOLS_VERSION-$DROOLS_CLASSIFIER.war && \
unzip -q /opt/jboss/$DROOLS_CONTEXT_PATH.war -d /opt/jboss/wildfly/standalone/deployments/$DROOLS_CONTEXT_PATH.war && \
touch /opt/jboss/wildfly/standalone/deployments/$DROOLS_CONTEXT_PATH.war.dodeploy && \
rm -rf /opt/jboss/$DROOLS_CONTEXT_PATH.war

####### EXPOSE INTERNAL JBPM GIT PORT ############
EXPOSE 8001

####### RUNNING DROOLS-WB ############
WORKDIR /opt/jboss/wildfly/bin/
CMD ["./standalone.sh", "-b", "0.0.0.0", "--server-config=standalone-full.xml"]
244 changes: 244 additions & 0 deletions drools-wb/base/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@
Drools Workbench Docker image
==============================

JBoss Drools Workbench [Docker](http://docker.io/) image.

Table of contents
------------------

* **[Introduction](#introduction)**
* **[Usage](#usage)**
* **[Users and roles](#users-and-roles)**
* **[Logging](#logging)**
* **[Extending this image](#extending-this-image)**
* **[Experimenting](#experimenting)**
* **[Notes](#notes)**

Introduction
------------

The image contains:
* JBoss Wildfly 8.1.0.Final
* Drools Workbench 6.2.0.Final

This image provides the Drools Workbench but it's intended to be extended so you can add your custom configurations such as users, roles, etc.

If you don't want to extend this image and you just want to try Drools Workbench take a look at the Docker image **<code>jboss/drools-workbench-showcase:6.2.0</code>**, it contains default users and roles and allows using the application with no custom configurations.


Usage
-----

To run a container:

docker run -P -d --name drools-workbench jboss/drools-workbench:6.2.0

Once container and web applications started, you can navigate to it:

**Using local host binding port**

If you have run the container using <code>-P</code> flag in the <code>docker</code> command, the port <code>8080</code> has been bind to an available port on your host.

So you have to discover your host's bind port, that can be done by running the command:

docker ps -a

Example of the above command response:

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2a55fbe771c0 jboss/drools-workbench:6.2.0 ./standalone.sh -b 0 About a minute ago Up About a minute 0.0.0.0:49159->8080/tcp, 0.0.0.0:49160->9990/tcp drools-workbench

As you can see, the bind port to use for container's port <code>8080</code> is <code>49159</code>, so you can navigate to:

http://localhost:49159/drools-wb

**No bind port for localhost**

In case you run the container without using <code>-P</code> flag in the <code>docker</code> command, you can navigate to the application at:

http://<container_ip_address>:8080/drools-wb

You can discover the IP address of your running container by:

docker inspect --format '{{ .NetworkSettings.IPAddress }}' drools-workbench


Users and roles
----------------

The application have no users or roles configured, so you cannot not access it by default,

In order to use it, at least you have to create an application user in JBoss Wildfly with role <code>admin</code>.

If you are looking for a Drools Workbench image that does not require to add custom configurations, try our **<code>jboss/drools-workbench-showcase:6.2.0</code>** Docker image.

If you want to create your custom configuration and users, role, etc, you can take a look at section [Extending this image](#extending-this-image).


Logging
-------

You can see all logs generated by the <code>standalone</code> binary running:

docker logs [-f] <container_id>

You can attach the container by running:

docker attach <container_id>

The Drools Workbench web application logs can be found inside the container at path:

/opt/jboss/wildfly/standalone/log/server.log

Example:
sudo nsenter -t $(docker inspect --format '{{ .State.Pid }}' $(docker ps -lq)) -m -u -i -n -p -w
-bash-4.2# tail -f /opt/jboss/wildfly/standalone/log/server.log

Extending this image
--------------------

You can extend this image and add your custom layers in order to add custom configurations, users, roles, etc.

In order to extend this image, your Dockerfile must inherit from:

FROM jboss/drools-workbench:6.2.0

**Configuring Wildfly**

* The Wildfly configuration files are located at <code>/opt/jboss/wildfly/standalone/configuration</code>
* In this file you can modify all Wildfly's subsystem configurations
* Drools Workbench requires running Wildfly using <code>full</code> profile, so custom modifications should be done in <code>standalone-full.xml</code> configuration file
* It's recommended if there are several modifications to do, to create a copy of the configuration file, rename it and use it to start Wildfly. If you do that, your Dockerfile must run Wildfly using this configuration file, so your <code>CMD</code> command should be as:

CMD ["./standalone.sh", "-b", "0.0.0.0", "--server-config=your-standalone-full.xml"]

**Users and roles**

* By default this image does not provide users and roles for Drools Workbench

* The available roles for Drools Workbench examples are:

<table>
<tr>
<td><b>Role</b></td>
<td><b>Description</b></td>
</tr>
<tr>
<td>admin</td>
<td>The administrator</td>
</tr>
<tr>
<td>analyst</td>
<td>The analyst</td>
</tr>
<tr>
<td>developer</td>
<td>The developer</td>
</tr>
<tr>
<td>manager</td>
<td>The manager</td>
</tr>
<tr>
<td>user</td>
<td>The end user</td>
</tr>
<tr>
<td>kiemgmt</td>
<td>KIE management user</td>
</tr>
<tr>
<td>Accounting</td>
<td>Accounting role</td>
</tr>
<tr>
<td>PM</td>
<td>Project manager role</td>
</tr>
<tr>
<td>HR</td>
<td>Human resources role</td>
</tr>
<tr>
<td>sales</td>
<td>Sales role</td>
</tr>
<tr>
<td>IT</td>
<td>IT role</td>
</tr>
</table>

These are the steps to create your custom users and roles by using realm files in Widlfly:

1.- Create a realm properties file for users and deploy it in <code>/opt/jboss/wildfly/standalone/configuration</code>:

drools-users.properties
---------------------
admin=admin
analyst=analyst
developer=developer
manager=manager
user=user
2.- Create a realm properties file for roles and deploy it in <code>/opt/jboss/wildfly/standalone/configuration</code>:

drools-roles.properties
---------------------
admin=admin
analyst=analyst
developer=developer
manager=manager
user=user

3.- Modify your <code>standalone-full.xml</code> in order to:

3.1 - In the <code>management</code> section, modify default the security-realm for the <code>ApplicationRealm</code> as:

<security-realm name="ApplicationRealm">
<authentication>
<local default-user="$local" allowed-users="*" skip-group-loading="true"/>
<properties path="drools-users.properties" relative-to="jboss.server.config.dir"/>
</authentication>
<authorization>
<properties path="drools-roles.properties" relative-to="jboss.server.config.dir"/>
</authorization>
</security-realm>
3.2 - In the <code>security</code> subsystem, modify default the <code>other</code> security-domain for as:

<security-domain name="other" cache-type="default">
<authentication>
<login-module code="UsersRoles" flag="required">
<module-option name="usersProperties" value="${jboss.server.config.dir}/drools-users.properties"/>
<module-option name="rolesProperties" value="${jboss.server.config.dir}/drools-roles.properties"/>
</login-module>
</authentication>
</security-domain>

You can find an example by looking at the Dockerfile for <code>jboss/drools-workbench-showcase:6.2.0</code> image.

Experimenting
-------------

To spin up a shell in one of the containers try:

docker run -t -i -P jboss/drools-workbench:6.2.0 /bin/bash

You can then noodle around the container and run stuff & look at files etc.

You can run the Drools Workbench web application by running command:

/opt/jboss/wildfly/bin/standalone.sh -b 0.0.0.0 --server-config=standalone-full.xml


Notes
-----

* Drools Workbench version is <code>6.2.0.Final</code>
* Drools Workbench requires running JBoss Wildfly using <code>full</code> profile
* No users or roles are configured by default
* No support for clustering
* Use of embedded H2 database server by default
* No support for Wildfly domain mode, just standalone mode
* The context path for Drools Workbench web application is <code>drools-wb</code>
13 changes: 13 additions & 0 deletions drools-wb/base/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

# *********************************************
# Drools Workbench - Docker image build script
# ********************************************

IMAGE_NAME="jboss/drools-workbench"
IMAGE_TAG="6.2.0"

# Build the container image.
echo "Building the Docker container for $IMAGE_NAME:$IMAGE_TAG.."
docker build --rm -t $IMAGE_NAME:$IMAGE_TAG .
echo "Build done"
59 changes: 59 additions & 0 deletions drools-wb/base/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/sh

# ********************************************
# Drools Workbench - Docker image start script
# ********************************************

# Program arguments
#
# -c | --container-name: The name for the created container.
# If not specified, defaults to "drools-workbench"
# -h | --help; Show the script usage
#

CONTAINER_NAME="drools-workbench"
IMAGE_NAME="jboss/drools-workbench"
IMAGE_TAG="6.2.0"

function usage
{
echo "usage: start.sh [ [-c <container_name> ] ] [-h]]"
}

while [ "$1" != "" ]; do
case $1 in
-c | --container-name ) shift
CONTAINER_NAME=$1
;;
-h | --help ) usage
exit
;;
* ) usage
exit 1
esac
shift
done

# Check if container is already started
if [ -f docker.pid ]; then
echo "Container is already started"
container_id=$(cat docker.pid)
echo "Stoping container $container_id..."
docker stop $container_id
rm -f docker.pid
fi

# Start the docker container
echo "Starting $CONTAINER_NAME docker container using:"
echo "** Container name: $CONTAINER_NAME"
image_drools_workbench=$(docker run -P -d --name $CONTAINER_NAME $IMAGE_NAME:$IMAGE_TAG)
ip_drools_workbench=$(docker inspect $image_drools_workbench | grep IPAddress | awk '{print $2}' | tr -d '",')
echo $image_drools_workbench > docker.pid

# End
echo ""
echo "Server starting in $ip_drools_workbench"
echo "You can access the server root context in http://$ip_drools_workbench:8080"
echo "JBoss Drools Workbench is running at http://$ip_drools_workbench:8080/drools-wb"

exit 0
Loading

0 comments on commit 1ef7f71

Please sign in to comment.