Fin dockerisation
This commit is contained in:
parent
945c57ddfd
commit
e203d7539c
21 changed files with 335 additions and 190 deletions
|
|
@ -147,8 +147,8 @@
|
|||
<orderEntry type="library" name="Maven: com.google.guava:guava:13.0.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-io:commons-io:2.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.9.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie:kie-internal:7.17.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie:kie-api:7.17.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie.soup:kie-soup-maven-support:7.17.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie:kie-internal:7.18.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie:kie-api:7.18.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie.soup:kie-soup-maven-support:7.18.0.Final" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
|
|
@ -3,7 +3,8 @@ FROM openjdk:8-jre-slim
|
|||
|
||||
ADD application.properties /application.properties
|
||||
ADD maven/drools-framework-business-indexer-app-1.0-SNAPSHOT.jar app.jar
|
||||
|
||||
RUN mkdir /root/.ssh
|
||||
RUN echo toto > /root/.ssh/known_hosts
|
||||
|
||||
|
||||
RUN bash -c 'touch /app.jar'
|
||||
|
|
|
|||
|
|
@ -7,6 +7,6 @@ import org.springframework.stereotype.Component;
|
|||
public class DeclareNewSftpRouter extends RouteBuilder {
|
||||
@Override
|
||||
public void configure() throws Exception {
|
||||
from("quartz2://myGroup/myTimerName?cron=0+0/1+*+?+*+MON-FRI").to("bean:startRouteService?method=updateConfig()");
|
||||
from("quartz2://myGroup/myTimerName?cron=0/5+*+*+?+*+*").to("bean:startRouteService?method=updateConfig()");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,8 +92,8 @@
|
|||
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.guava:guava:13.0.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-io:commons-io:2.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie:kie-internal:7.17.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie:kie-api:7.17.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie.soup:kie-soup-maven-support:7.17.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie:kie-internal:7.18.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie:kie-api:7.18.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie.soup:kie-soup-maven-support:7.18.0.Final" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
|
|
@ -266,8 +266,8 @@
|
|||
|
||||
<run>
|
||||
<extraHosts>
|
||||
<host>mongodb:172.17.0.1</host>
|
||||
<host>kie-wb:172.17.0.1</host>
|
||||
<host>mongodb:192.168.2.17</host>
|
||||
<host>kie-wb:192.168.2.17</host>
|
||||
</extraHosts>
|
||||
<ports>
|
||||
<port>8200:8200</port>
|
||||
|
|
|
|||
|
|
@ -1,18 +1,17 @@
|
|||
FROM openjdk:8-jre-slim
|
||||
|
||||
EXPOSE 8200
|
||||
EXPOSE 9080
|
||||
EXPOSE 8090
|
||||
ADD application.properties /application.properties
|
||||
ADD maven/drools-framework-business-proxy-app-1.0-SNAPSHOT.jar app.jar
|
||||
|
||||
USER root
|
||||
RUN mkdir /m2_kieserver
|
||||
RUN mkdir /m2_kieserver/repository
|
||||
ADD settings.xml /m2_kieserver/settings.xml
|
||||
RUN mkdir /trace
|
||||
RUN mkdir /niodir-kieserver
|
||||
|
||||
|
||||
RUN bash -c 'touch /app.jar'
|
||||
ENV JAVA_OPTS "-Dspring.config.location=file:./ -DM2_HOME=/m2_kieserver -Dorg.chtijbug.server.tracedir=/trace -Dorg.appformer.m2repo.url=http://kie-wb:8080/kie-wb/maven2 -Dorg.uberfire.nio.git.dir=/niodir-kieserver -Dkie.maven.settings.custom=/m2_kieserver/settings.xml -Dorg.kie.server.repo=/niodir-kieserver -Dfile.encoding=UTF-8 -Duser.language=fr -Duser.country=FR -Dorg.chtijbug.server.sftpPort=9080"
|
||||
|
||||
ENTRYPOINT ["java","-Dspring.config.location=file:/ -DM2_HOME=/m2_kieserver -Dorg.chtijbug.server.tracedir=/trace -Dorg.appformer.m2repo.url=http://kie-wb:8080/kie-wb/maven2 -Dorg.uberfire.nio.git.dir=/niodir-kieserver -Dkie.maven.settings.custom=/m2_kieserver/settings.xml -Dorg.kie.server.repo=/niodir-kieserver -Dfile.encoding=UTF-8 -Duser.language=fr -Duser.country=FR -Dorg.kie.server.id=server1 -Dorg.chtijbug.server.sftpPort=9080","-jar","/app.jar"]
|
||||
#ENTRYPOINT ["java","-jar","/app.jar"]
|
||||
ENTRYPOINT exec java $JAVA_OPTS -jar /app.jar
|
||||
|
|
@ -20,4 +20,4 @@ camel.springboot.name=MyCamel
|
|||
# to reconfigure the camel servlet context-path mapping to use /api/* instead of /camel/*
|
||||
camel.component.servlet.mapping.context-path=/api/*
|
||||
spring.data.mongodb.database=businessProxyDB
|
||||
spring.data.mongodb.host=mongodb:27017
|
||||
spring.data.mongodb.host=mongodb:27017
|
||||
|
|
|
|||
|
|
@ -19,6 +19,9 @@ package org.chtijbug.drools.proxy;
|
|||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
// CHECKSTYLE:OFF
|
||||
@SpringBootApplication
|
||||
public class DroolsBusinessProxyServer {
|
||||
|
|
@ -28,6 +31,16 @@ public class DroolsBusinessProxyServer {
|
|||
* Main method to start the application.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
if (System.getProperty("org.kie.server.id") == null) {
|
||||
InetAddress inetAddress = null;
|
||||
try {
|
||||
inetAddress = InetAddress.getLocalHost();
|
||||
String hostName = inetAddress.getHostName();
|
||||
System.setProperty("org.kie.server.id", hostName);
|
||||
} catch (UnknownHostException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
SpringApplication.run(DroolsBusinessProxyServer.class, args);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -88,11 +88,12 @@ public class KieServiceCommon {
|
|||
}
|
||||
this.marshallerHelper = new MarshallerHelper(this.server.getServerRegistry());
|
||||
|
||||
public static String getKieServerID(){
|
||||
return System.getProperty("org.kie.server.id");
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
private void initCamelBusinessRoutes() {
|
||||
String serverName = System.getProperty("org.kie.server.id");
|
||||
String serverName = KieServiceCommon.getKieServerID();
|
||||
String sftpPort = System.getProperty("org.chtijbug.server.sftpPort");
|
||||
List<RuntimePersist> itIsMes = runtimeRepository.findByServerName(serverName);
|
||||
if (itIsMes.size() == 0) {
|
||||
|
|
@ -125,7 +126,7 @@ public class KieServiceCommon {
|
|||
}
|
||||
@PreDestroy
|
||||
public void stopRuntime(){
|
||||
String serverName = System.getProperty("org.kie.server.id");
|
||||
String serverName =KieServiceCommon.getKieServerID();
|
||||
List<RuntimePersist> itIsMes = runtimeRepository.findByServerName(serverName);
|
||||
if (itIsMes.size()==1){
|
||||
RuntimePersist runtimePersist =itIsMes.get(0);
|
||||
|
|
@ -179,6 +180,13 @@ public class KieServiceCommon {
|
|||
}
|
||||
}
|
||||
|
||||
public DroolsChtijbugRulesExecutionService getDroolsChtijbugRulesExecutionService() {
|
||||
return droolsChtijbugRulesExecutionService;
|
||||
}
|
||||
|
||||
public KieServerRegistry getRegistry() {
|
||||
return registry;
|
||||
}
|
||||
|
||||
public KieServerImpl getServer() {
|
||||
return server;
|
||||
|
|
@ -207,7 +215,7 @@ public class KieServiceCommon {
|
|||
}
|
||||
|
||||
public void updateConfig() throws Exception {
|
||||
String serverName = System.getProperty("org.kie.server.id");
|
||||
String serverName = KieServiceCommon.getKieServerID();
|
||||
List<ContainerPojoPersist> containers = containerRepository.findByServerNameAndStatus(serverName, ContainerPojoPersist.STATUS.TODEPLOY.toString());
|
||||
for (ContainerPojoPersist element : containers) {
|
||||
this.disposeContainer(element.getContainerId());
|
||||
|
|
@ -246,7 +254,7 @@ public class KieServiceCommon {
|
|||
logger.info("GenericResource.runSession", e);
|
||||
}
|
||||
try {
|
||||
String serverName = System.getProperty("org.kie.server.id");
|
||||
String serverName = KieServiceCommon.getKieServerID();
|
||||
ContainerPojoPersist containerPojoPersist = containerRepository.findByServerNameAndContainerId(serverName, id);
|
||||
if (containerPojoPersist == null) {
|
||||
containerPojoPersist = new ContainerPojoPersist();
|
||||
|
|
@ -322,7 +330,7 @@ public class KieServiceCommon {
|
|||
|
||||
public ServiceResponse<Void> disposeContainer(String id) {
|
||||
ServiceResponse<Void> result = server.disposeContainer(id);
|
||||
String serverName = System.getProperty("org.kie.server.id");
|
||||
String serverName =KieServiceCommon.getKieServerID();
|
||||
ContainerPojoPersist element = containerRepository.findByServerNameAndContainerId(serverName, id);
|
||||
if (element != null) {
|
||||
containerRepository.delete(element);
|
||||
|
|
|
|||
|
|
@ -6,63 +6,41 @@ import org.chtijbug.drools.kieserver.extension.KieServerAddOnElement;
|
|||
import org.chtijbug.drools.kieserver.extension.KieServerLoggingDefinition;
|
||||
import org.chtijbug.drools.logging.SessionExecution;
|
||||
import org.chtijbug.kieserver.services.drools.ChtijbugObjectRequest;
|
||||
import org.chtijbug.kieserver.services.drools.DroolsChtijbugKieServerExtension;
|
||||
import org.chtijbug.kieserver.services.drools.DroolsChtijbugRulesExecutionService;
|
||||
import org.kie.server.services.api.KieContainerInstance;
|
||||
import org.kie.server.services.api.KieServerExtension;
|
||||
import org.kie.server.services.api.KieServerRegistry;
|
||||
import org.kie.server.services.impl.KieServerImpl;
|
||||
import org.kie.server.services.impl.KieServerLocator;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.temporal.ChronoField;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Service("ruleService")
|
||||
public class RuleService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(RuleService.class);
|
||||
private DroolsChtijbugRulesExecutionService droolsChtijbugRulesExecutionService = null;
|
||||
private DroolsChtijbugKieServerExtension droolsChtijbugKieServerExtension;
|
||||
private KieServerRegistry registry;
|
||||
private ObjectMapper mapper = new ObjectMapper();
|
||||
private KieServerImpl server;
|
||||
|
||||
@Inject
|
||||
private KieServiceCommon kieServiceCommon;
|
||||
|
||||
public RuleService() {
|
||||
this.server = KieServerLocator.getInstance();
|
||||
List<KieServerExtension> serverExtensions = this.server.getServerExtensions();
|
||||
for (KieServerExtension serverExtension : serverExtensions) {
|
||||
if (serverExtension instanceof DroolsChtijbugKieServerExtension) {
|
||||
droolsChtijbugKieServerExtension = (DroolsChtijbugKieServerExtension) serverExtension;
|
||||
if (droolsChtijbugRulesExecutionService == null) {
|
||||
|
||||
droolsChtijbugRulesExecutionService = droolsChtijbugKieServerExtension.getRulesExecutionService();
|
||||
}
|
||||
if (registry == null) {
|
||||
registry = droolsChtijbugRulesExecutionService.getContext();
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println("rulestep01");
|
||||
}
|
||||
|
||||
public Object runSessionObject(String transactionID, String id, String processID, Object input) throws IOException {
|
||||
KieContainerInstance kci = registry.getContainer(id);
|
||||
KieContainerInstance kci = kieServiceCommon.getRegistry().getContainer(id);
|
||||
ChtijbugObjectRequest chtijbugObjectRequest = new ChtijbugObjectRequest();
|
||||
chtijbugObjectRequest.setObjectRequest(input);
|
||||
KieServerAddOnElement kieServerAddOnElement = droolsChtijbugRulesExecutionService.getKieServerAddOnElement();
|
||||
KieServerAddOnElement kieServerAddOnElement = kieServiceCommon.getDroolsChtijbugRulesExecutionService().getKieServerAddOnElement();
|
||||
if (kieServerAddOnElement != null) {
|
||||
for (KieServerLoggingDefinition kieServerLoggingDefinition : kieServerAddOnElement.getKieServerLoggingDefinitions()) {
|
||||
kieServerLoggingDefinition.OnFireAllrulesStart(kci.getKieContainer().getReleaseId().getGroupId(), kci.getKieContainer().getReleaseId().getArtifactId(), kci.getKieContainer().getReleaseId().getVersion(), input);
|
||||
}
|
||||
}
|
||||
ChtijbugObjectRequest chtijbutObjectResponse = droolsChtijbugRulesExecutionService.FireAllRulesAndStartProcess(kci, chtijbugObjectRequest, processID);
|
||||
ChtijbugObjectRequest chtijbutObjectResponse = kieServiceCommon.getDroolsChtijbugRulesExecutionService().FireAllRulesAndStartProcess(kci, chtijbugObjectRequest, processID);
|
||||
/**
|
||||
* remove facts from logging to avoid infinite loop when marshalling to json and size of logging
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -90,4 +90,141 @@
|
|||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring.boot-version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>docker-build</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>io.fabric8</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
<version>0.21.0</version>
|
||||
|
||||
<configuration>
|
||||
<!--registry>192.168.1.184:12500</registry-->
|
||||
<dockerHost>${docker.Host}</dockerHost>
|
||||
|
||||
<!-- this is for Mac and Amazon Linux -->
|
||||
<!--dockerHost>unix:///var/run/docker.sock</dockerHost-->
|
||||
|
||||
<verbose>true</verbose>
|
||||
<images>
|
||||
<image>
|
||||
<name>runtime-reverse-proxy</name>
|
||||
<build>
|
||||
<dockerFileDir>${project.basedir}/src/main/docker</dockerFileDir>
|
||||
|
||||
<!--copies Jar to the maven directory (uses Assembly system)-->
|
||||
<assembly>
|
||||
<descriptorRef>artifact</descriptorRef>
|
||||
</assembly>
|
||||
<tags>
|
||||
<tag>latest</tag>
|
||||
</tags>
|
||||
|
||||
</build>
|
||||
|
||||
<run>
|
||||
<extraHosts>
|
||||
<host>mongodb:192.168.43.94</host>
|
||||
</extraHosts>
|
||||
|
||||
</run>
|
||||
</image>
|
||||
</images>
|
||||
</configuration>
|
||||
|
||||
<executions>
|
||||
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>build</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
|
||||
|
||||
</executions>
|
||||
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>docker-deploy</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>io.fabric8</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
<version>0.21.0</version>
|
||||
|
||||
<configuration>
|
||||
<!--registry>192.168.1.184:12500</registry-->
|
||||
<dockerHost>${docker.Host}</dockerHost>
|
||||
|
||||
<!-- this is for Mac and Amazon Linux -->
|
||||
<!--dockerHost>unix:///var/run/docker.sock</dockerHost-->
|
||||
|
||||
<verbose>true</verbose>
|
||||
<images>
|
||||
<image>
|
||||
<name>runtime-reverse-proxy</name>
|
||||
<build>
|
||||
<dockerFileDir>${project.basedir}/src/main/docker</dockerFileDir>
|
||||
|
||||
<!--copies Jar to the maven directory (uses Assembly system)-->
|
||||
<assembly>
|
||||
<descriptorRef>artifact</descriptorRef>
|
||||
</assembly>
|
||||
<tags>
|
||||
<tag>latest</tag>
|
||||
</tags>
|
||||
|
||||
</build>
|
||||
|
||||
<run>
|
||||
<extraHosts>
|
||||
<host>mongodb:192.168.1.100</host>
|
||||
</extraHosts>
|
||||
|
||||
</run>
|
||||
</image>
|
||||
</images>
|
||||
</configuration>
|
||||
|
||||
<executions>
|
||||
|
||||
|
||||
<execution>
|
||||
<id>mydeploy</id>
|
||||
<phase>deploy</phase>
|
||||
<goals>
|
||||
<goal>push</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
|
||||
</executions>
|
||||
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
FROM openjdk:8-jre-slim
|
||||
|
||||
|
||||
ADD application.properties /application.properties
|
||||
ADD maven/drools-framework-business-reverse-proxy-1.0-SNAPSHOT.jar app.jar
|
||||
|
||||
|
||||
|
||||
RUN bash -c 'touch /app.jar'
|
||||
|
||||
ENTRYPOINT ["java","-Dspring.config.location=file:./","-jar","/app.jar"]
|
||||
#ENTRYPOINT ["java","-jar","/app.jar"]
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
server.port=9500
|
||||
|
||||
spring.data.mongodb.database=businessProxyDB
|
||||
spring.data.mongodb.host=mongodb:27017
|
||||
Loading…
Add table
editor.link_modal.header
Reference in a new issue