Config kie smart router for kie server

501 views Asked by At

I use jboss/kie-server-showcass image to run kie server. I want to know How can I config kie smart router for image file. I pass KIE_SERVER_ROUTER as environment when execute docker run command:

docker run -p 8180:8080 -d --name kie-server -e KIE_SERVER_ROUTER=http://172.17.0.1:9000 --link jbpm-workbench:kie-wb jboss/kie-server-showcase:latest

but it doesn't work and the kie server can't register to kie smart router.

I clone the https://github.com/jboss-dockerfiles/business-central and in kieserver/showcase/etc change the start_kie-server.sh file and modify JBOSS_ARGUMENTS:

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 -Dorg.kie.server.router=http://172.17.0.1:9000"

and add -Dorg.kie.server.router=http://172.17.0.1:9000" to JBOSS_ARGUMENTS, and kie server registered to kie smart router successfully. But I don't what modify original image, to do register kie server. Is there anyway to register kie server as a docker container to kie smart router?

1

There are 1 answers

0
lukas On

Hello had the same issue First Build kie router image : You need to have kie smart router jar you can download it from the Redhat site

####### BASE ############
FROM jboss/base-jdk:8

####### ENVIRONMENT ############
ENV ROUTER_HOME=/opt/jboss \
    KIE_SERVER_ROUTER_REPO_DIR=/opt/jboss \
    ROUTER_HOSTNAME_EXTERNAL=http://localhost:9000/

# ENV KIE_SERVER_CONTROLLER
ENV KIE_SERVER_CONTROLLER_USER admin
ENV KIE_SERVER_CONTROLLER_PWD admin


####### EXPOSE ROUTER PORT ############
EXPOSE 9000


####### Kie server router CUSTOM CONFIGURATION ############
ADD kie-server-router.jar $ROUTER_HOME/kie-server-router.jar
ADD start_kie-server-router.sh $ROUTER_HOME/start_kie-server-router.sh


###### SWITCH USER root ######
USER root


###### CHANGE FILE PROPERTIES ######
RUN chmod +x $ROUTER_HOME/start_kie-server-router.sh
RUN chgrp -R 0 /opt/jboss
RUN chmod -R g+rw /opt/jboss
RUN find /opt/jboss -type d -exec chmod g+x {} +


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


####### RUNNING Kie server router ############
WORKDIR $ROUTER_HOME
CMD ["./start_kie-server-router.sh"

start_kie-server-router.sh :

#!/usr/bin/env bash


# Default arguments for running the KIE Execution server.
ROUTER_ARGUMENTS="-Dorg.kie.server.router.host=$HOSTNAME -Dorg.kie.server.router.port=9000 -Dorg.kie.server.router.repo=$KIE_SERVER_ROUTER_REPO_DIR -Dorg.kie.server.router.url.external=$ROUTER_HOSTNAME_EXTERNAL"


# Controller argument for the KIE Server router. 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"
    ROUTER_ARGUMENTS="$ROUTER_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


echo "Router arguments '$ROUTER_ARGUMENTS' "


exec java -jar $ROUTER_ARGUMENTS $ROUTER_HOME/kie-server-router.jar
exit $?

Build kie server image where you will be using smart router option clone this repo : https://github.com/jboss-dockerfiles/business-central/tree/master/kie-server/showcase

In Dockerfile edit

ENV KIE_SERVER_LOCATION http://kie-server:8080/kie-server/services/rest/server

In start_kie-server.sh add

# If Kie server router is configured then use it
if [ -n "$KIE_SERVER_ROUTER" ]; then
    echo "Using '$KIE_SERVER_ROUTER' as KIE server router"
    JBOSS_ARGUMENTS="$JBOSS_ARGUMENTS -Dorg.kie.server.router=$KIE_SERVER_ROUTER"
fi

Finally docker compose

business-central:
    image: jboss/business-central-workbench-showcase
    container_name: business-central
    ports:
      - 8080:8080
      - 8001:8001
  kie-server:
    image: jboss/kie-server-showcase:{yourTag}
    container_name: kie-server
    environment:
      KIE_MAVEN_REPO: http://nexus:8081/repository/rules
      JVM_OPTS: -Xmx1g -Xms1g
      KIE_SERVER_CONTROLLER: http://business-central:8080/business-central/rest/controller
      KIE_SERVER_ROUTER: http://kie-smart-router:9000
    depends_on:
      - nexus
      - business-central
      - kie-smart-router
    ports:
      - 8180:8080
  kie-smart-router:
    image: jboss/kie-smart-router:latest
    container_name: kie-smart-router
    environment:
      KIE_SERVER_CONTROLLER: http://business-central:8080/business-central/rest/controller
    depends_on:
      - business-central
    ports:
      - 9000:9000