Commit 68720723 authored by danushka9999's avatar danushka9999

KIE server structure

parent db8049b7
# These are some examples of commonly ignored file patterns.
# You should customize this list as applicable to your project.
# Learn more about .gitignore:
# https://www.atlassian.com/git/tutorials/saving-changes/gitignore
# Node artifact files
node_modules/
dist/
# Compiled Java class files
*.class
# Compiled Python bytecode
*.py[cod]
# Log files
*.log
# Package files
*.jar
# Maven
target/
dist/
# JetBrains IDE
.idea/
# Unit test reports
TEST*.xml
# Generated by MacOS
.DS_Store
# Generated by Windows
Thumbs.db
# Applications
*.app
*.exe
*.war
# Large media files
*.mp4
*.tiff
*.avi
*.flv
*.mov
*.wmv
FROM jboss/kie-server:7.46.0.Final
####### Drools KIE Server CUSTOM CONFIGURATION ############
RUN mkdir -p $HOME/.m2
ADD standalone-full-kie-server.xml $JBOSS_HOME/standalone/configuration/standalone-full-kie-server.xml
ADD kie-server-users.properties $JBOSS_HOME/standalone/configuration/kie-server-users.properties
ADD kie-server-roles.properties $JBOSS_HOME/standalone/configuration/kie-server-roles.properties
ADD start_kie-server.sh $JBOSS_HOME/bin/start_kie-server.sh
ADD settings.xml $JBOSS_HOME/../.m2/settings.xml
# Added files are chowned to root user, change it to the jboss one.
USER root
RUN chmod +x $JBOSS_HOME/standalone/configuration/standalone-full-kie-server.xml && \
chmod +x $JBOSS_HOME/standalone/configuration/kie-server-users.properties && \
chmod +x $JBOSS_HOME/standalone/configuration/kie-server-roles.properties && \
chmod +x $JBOSS_HOME/bin/start_kie-server.sh && \
chmod +x $JBOSS_HOME/../.m2/settings.xml
####### JBOSS USER ############
# Switchback to jboss user
USER jboss
####### RUNNING KIE-SERVER ############
WORKDIR $JBOSS_HOME/bin/
CMD ["./start_kie-server.sh"]
\ No newline at end of file
import groovy.transform.Field
@Field def projectName = "kie-server" // name of the current application we're running CI/CD for
@Field def branchName = "unknown" // name of the current branch to checkout for the application
@Field def buildNumber = "unknown" // current Jenkins build number
@Field def devopsBranch = "master" // branch for winnow-devops; should always be master, unless for devops testing
@Field def slackChannel = "platform_ci" // slack channel where the notifications will be pushed
@Field def jobBaseName = "unknown" // name of the Jenkins job
@Field def jenkinsSrvName = "unknown" // name of the Jenkins server
@Field def VERSION = "unknown" // application version
@Field def IMAGE = "kie-server" // Docker image name,
@Field def codePath = "" // path of application code
@Field def environment = "" // environment specifier -- i.e: prod, uat, dynX
@Field def deployable = true // variable to check if we should deploy -- currently checks for version diffs between pom.xml and git tag
@Field def service_type = "platform"
@Field def jenkins_node = "jenkins-slave-hub"
try {
node("$jenkins_node") {
slackNotifyBuild('PIPELINE STARTED')
stage('Project setup') {
dir("app/${projectName}") {
//checking out the app code
echo 'Checkout the code..'
checkout scm
branchName = env.BRANCH_NAME
buildNumber = env.BUILD_NUMBER
jobBaseName = "${env.JOB_NAME}".split('/').last() // We want to get the name of the branch/tag
jenkinsSrvName = env.BUILD_URL.split('/')[2].split(':')[0]
echo "Jenkins checkout from branch: $branchName && $buildNumber"
echo "Running job ${jobBaseName} on jenkins server ${jenkinsSrvName}"
codePath = pwd()
}
}
}
}
catch (e) {
// If there was an exception thrown, the build failed
currentBuild.result = "FAILED"
slackNotifyBuild("PIPELINE FAILED")
throw e
}
// figure out next steps depending on the name of the job (which is a git tag)
// x.x.x -- prod CD
// rc-x.x.x -- UAT CI/CD
// anything else -- CI
switch (jobBaseName) {
// PROD tag job
case ~/^\d+\.\d+\.\d+$/:
// trigger Jenkinsfile-prod-deploy
environment = "prod"
VERSION = "$jobBaseName"
pipelineCD()
break
// UAT tag job
case ~/^rc-\d+\.\d+\.\d+$/:
//trigger Jenkinfile-uat-deploy
VERSION = "$jobBaseName".replaceAll("rc-","")
echo "Deploy to UAT version: $VERSION"
environment = "uat"
pipelineCD()
break
default:
echo "Unfortunatly the deployment of opa is not available for dyn"
break
}
// This method will help us notify in the slack channel
def slackNotifyBuild(String buildStatus = 'BUILD STARTED') {
// build status of null means successful
buildStatus = buildStatus ?: 'SUCCESSFUL'
// Default values
def jobBaseName = "${env.JOB_NAME}".split('/').first()
def colorName = 'RED'
def colorCode = '#FF0000'
def subject = "${buildStatus}: Pipeline `${jobBaseName}` on branch `${env.BRANCH_NAME}` and build `#${env.BUILD_NUMBER}`"
def summary = "${subject} (${env.BUILD_URL})"
// Override default values based on build status
switch (buildStatus) {
case "BUILD STARTED":
color = 'YELLOW'
colorCode = '#FFFF00'
break
case "PIPELINE STARTED":
color = 'YELLOW'
colorCode = '#FFFF00'
break
case "BUILD SUCCESSFUL":
color = 'BLUE'
colorCode = '#4186f4'
break
case "BUILD UNSTABLE":
color = 'ORANGE'
colorCode = '#FF8C00'
break
case "DELIVERY STARTED":
color = 'YELLOW'
colorCode = '#FFFF00'
break
case "DELIVERY SUCCESSFUL":
color = 'GREEN'
colorCode = '#30873a'
break
case "DEPLOY STARTED":
color = 'YELLOW'
colorCode = '#FFFF00'
break
case "DEPLOY SUCCESSFUL":
color = 'BLUE'
colorCode = '#42f4f4'
break
default:
color = 'RED'
colorCode = '#FF0000'
break
}
// Send notifications
if( env.BRANCH_NAME == "dev" || env.BRANCH_NAME == "master" ) {
slackSend (color: colorCode, message: summary, channel: "${slackChannel}")
}
}
def pipelineCD(Map args = [:]) {
node("$jenkins_node") {
stage('Prepare CD') {
try {
dir('app/winnow-devops') {
git(
poll: true,
url: 'git@bitbucket.org:teamwinnow/winnow-devops.git',
credentialsId: 'd6e1be13-06a3-4823-8872-2fd509fca9b9',
branch: "$devopsBranch"
)
withEnv(["projectName=$projectName", "jenkins_node=$jenkins_node" ,"service_type=$service_type", "jobBaseName=$jobBaseName", "slackChannel=$slackChannel", "IMAGE=$IMAGE", "environment=$environment", "VERSION=$VERSION", "codePath=$codePath"]) {
load "jenkins/files/$service_type/Jenkinsfile-$environment-deploy"
}
}
} catch (e) {
throw e
}
}
}
}
\ No newline at end of file
# README #
### What is this repository for? ###
This represents the Kie Server. It's basically the rules engine, though it can have more capabilities than rules.
Once we start this we can run the rules we create in the drools-workbench. We can start it embedded also in our application
but we lose the ability to develop rules faster. Once we create a rule in workbench we can deploy it on the KIE server and our
application will interact with it.
For a quick startup this is a pre-setup image with roles and users. This should be temporary and we need to revisit it.
### How do I get set up? ###
Just build the docker image. Again the Dockerfile is simple but we intend to put more there.
This is in case you are wondering why not using directly the official image.
```
docker build -t my-kie .
```
Start by running
```
docker run -p 8180:8080 -d --name kie-server --link drools-wb:kie-wb my-kie:latest
```
drools-wb is the drools workbench container name. By linking them workbench can see all kie instances.
Go to
```
http://localhost:8180/kie-server
```
and login using one of the users available.
OR
assuming kie server deployed at 172.17.0.3
and workbench at 172.17.0.2
```
docker run -p 8180:8080 -d --name kie-server2 \
-e KIE_SERVER_LOCATION=http://172.17.0.3:8080/kie-server/services/rest/server \
-e KIE_SERVER_CONTROLLER=http://172.17.0.2:8080/business-central/rest/controller \
-e KIE_SERVER_CONTROLLER_USER=admin \
-e KIE_SERVER_CONTROLLER_PWD=admin \
-e KIE_SERVER_PWD=kieserver1! \
-e KIE_SERVER_USER=kieserver \
-e KIE_MAVEN_REPO=http://172.17.0.2:8080/business-central/maven2 \
-e KIE_MAVEN_REPO_USER=admin \
-e KIE_MAVEN_REPO_PASSWORD=admin \
my-kie:latest
```
### Who do I talk to? ###
For more information contact Sergiu Oltean or go to https://registry.hub.docker.com/r/jboss/kie-server-showcase.
\ No newline at end of file
kieserver=kie-server
admin=kie-server
krisv=kie-server
john=kie-server
sales-rep=kie-server
katy=kie-server
jack=kie-server
\ No newline at end of file
kieserver=kieserver1!
admin=admin
krisv=krisv
john=john
sales-rep=sales-rep
katy=katy
jack=jack
\ No newline at end of file
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!-- CUSTOM settings.xml for KIE Execution Server
*********************************************
- This is the custom settings.xml file used for KIE Execution Server to download the artifacts from the Maven repository
provided by the Drools WB internals.
- This file is deployed into jboss user home at $HOME/.m2/settings.xml
- This file uses system environment variables to point to the Drools WB Docker container that provides the Maven repository. These variables are:
KIE_MAVEN_REPO - Defaults to http://localhost:8080/drools-wb/maven2
KIE_MAVEN_REPO_USER - Defaults to admin
KIE_MAVEN_REPO_PASSWORD - Defaults to admin
-->
<settings>
<localRepository>${env.HOME}/.m2/repository</localRepository>
<proxies>
</proxies>
<servers>
<server>
<id>kie-workbench</id>
<username>${env.KIE_MAVEN_REPO_USER}</username>
<password>${env.KIE_MAVEN_REPO_PASSWORD}</password>
<configuration>
<wagonProvider>httpclient</wagonProvider>
<httpConfiguration>
<all>
<usePreemptive>true</usePreemptive>
</all>
</httpConfiguration>
</configuration>
</server>
</servers>
<mirrors>
</mirrors>
<profiles>
<profile>
<id>kie</id>
<properties>
</properties>
<repositories>
<repository>
<id>jboss-public-repository-group</id>
<name>JBoss Public Maven Repository Group</name>
<url>https://repository.jboss.org/nexus/content/groups/public-jboss/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
<repository>
<id>kie-workbench</id>
<name>JBoss BRMS Guvnor M2 Repository</name>
<url>${env.KIE_MAVEN_REPO}</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>jboss-public-repository-group</id>
<name>JBoss Public Maven Repository Group</name>
<url>https://repository.jboss.org/nexus/content/groups/public-jboss/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>kie</activeProfile>
</activeProfiles>
</settings>
\ No newline at end of file
#!/usr/bin/env bash
# If not server identifier set via docker env variable, use the container's hostname as server id.
if [ ! -n "$KIE_SERVER_ID" ]; then
export KIE_SERVER_ID=kie-server-$HOSTNAME
fi
echo "Using '$KIE_SERVER_ID' as KIE server identifier"
# If this KIE execution server container is linked with some KIE Workbench container, the following environemnt variables will be present, so configure the application arguments based on their values.
if [ -n "$KIE_WB_PORT_8080_TCP" ] && [ -n "$KIE_WB_ENV_KIE_CONTEXT_PATH" ] && [ -n "$KIE_WB_PORT_8080_TCP_ADDR" ]; then
# If not public IP configured using the DOCKER_IP env, obtain the internal network address for this container.
if [ ! -n "$DOCKER_IP" ]; then
# Obtain current container's IP address.
DOCKER_IP=$(/sbin/ifconfig eth0 | grep 'inet' | cut -d: -f2 | awk '{ print $2}')
fi
# If not public port configured using the DOCKER_PORT env, use the default internal network HTTP port.
if [ ! -n "$DOCKER_PORT" ]; then
DOCKER_PORT=8080
fi
# KIE Workbench environment variables are set. Proceed with automatic configuration.
echo "Detected successful link for KIE Workbench container. Applying automatic configuration for the link..."
export KIE_SERVER_LOCATION="http://$DOCKER_IP:$DOCKER_PORT/$KIE_CONTEXT_PATH/services/rest/server"
export KIE_SERVER_CONTROLLER="http://$KIE_WB_PORT_8080_TCP_ADDR:8080/$KIE_WB_ENV_KIE_CONTEXT_PATH/rest/controller"
export KIE_MAVEN_REPO="http://$KIE_WB_PORT_8080_TCP_ADDR:8080/$KIE_WB_ENV_KIE_CONTEXT_PATH/maven2"
fi
# Default arguments for running the KIE Execution server.
JBOSS_ARGUMENTS=" -b $JBOSS_BIND_ADDRESS -Dorg.kie.server.id=$KIE_SERVER_ID -Dorg.kie.server.user=$KIE_SERVER_USER -Dorg.kie.server.pwd=$KIE_SERVER_PWD -Dorg.kie.server.location=$KIE_SERVER_LOCATION "
echo "Using '$KIE_SERVER_LOCATION' as KIE server location"
# Controller argument for the KIE Execution server. Only enabled if set the environment variable/s or detected container linking.
if [ -n "$KIE_SERVER_CONTROLLER" ]; then
echo "Using '$KIE_SERVER_CONTROLLER' as KIE server controller"
echo "Using '$KIE_MAVEN_REPO' for the kie-workbench Maven repository URL"
JBOSS_ARGUMENTS="$JBOSS_ARGUMENTS -Dorg.kie.server.controller=$KIE_SERVER_CONTROLLER -Dorg.kie.server.controller.user=$KIE_SERVER_CONTROLLER_USER -Dorg.kie.server.controller.pwd=$KIE_SERVER_CONTROLLER_PWD "
fi
CUSTOM_ARGS=" -Dorg.jbpm.server.ext.disabled=true -Dorg.jbpm.ui.server.ext.disabled=true -Dorg.optaplanner.server.ext.disabled=true -Dorg.kie.executor.disabled=true -Ddrools.externaliseCanonicalModelLambda=true"
# Start Wildfly with the given arguments.
echo "Running KIE Execution Server on JBoss Wildfly..."
exec ./standalone.sh $JBOSS_ARGUMENTS $CUSTOM_ARGS -c standalone-full-kie-server.xml
exit $?
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment