0

我使用 jboss/kie-server-showcass 图像来运行 kie 服务器。我想知道如何为图像文件配置 kie 智能路由器。执行 docker run 命令时,我将 KIE_SERVER_ROUTER 作为环境传递:

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

但它不起作用,并且kie服务器无法注册到kie智能路由器。

我克隆https://github.com/jboss-dockerfiles/business-centralkieserver/showcase/etc更改start_kie-server.sh文件并修改 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"

并添加-Dorg.kie.server.router=http://172.17.0.1:9000"到JBOSS_ARGUMENTS,kie服务器注册到kie智能路由器成功。但我不修改原始图像,注册kie服务器。无论如何将kie服务器注册为docker容器到kie智能路由器?

4

1 回答 1

0

你好有同样的问题首先构建 kie 路由器图像:你需要有 kie 智能路由器 jar,你可以从 Redhat 站点下载它

####### 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 $?

构建 kie 服务器映像,您将在其中使用智能路由器选项克隆此 repo:https ://github.com/jboss-dockerfiles/business-central/tree/master/kie-server/showcase

在 Dockerfile 中编辑

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

在 start_kie-server.sh 添加

# 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

最后 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 
于 2020-10-06T13:44:20.577 回答