use of org.kie.kogito.tracing.decision.quarkus.devservices.TrustyServiceInMemoryContainer in project kogito-runtimes by kiegroup.
the class KogitoDevServicesProcessor method startTrustyService.
private TrustyServiceInstance startTrustyService(final TrustyServiceDevServiceConfig config, final DevServicesConfig devServicesConfig, final LaunchModeBuildItem launchMode, final boolean useSharedNetwork) {
if (!config.devServicesEnabled) {
// explicitly disabled
LOGGER.info("Not starting DevServices for Kogito, as it has been disabled in the config.");
return null;
}
if (!isDockerWorking.getAsBoolean()) {
LOGGER.warn("Docker isn't working, unable to start TrustyService image.");
return null;
}
final Optional<ContainerAddress> maybeContainerAddress = LOCATOR.locateContainer(config.serviceName, config.shared, launchMode.getLaunchMode());
// Starting TrustyService
final Supplier<TrustyServiceInstance> trustyServiceSupplier = () -> {
try {
TrustyServiceInMemoryContainer container = new TrustyServiceInMemoryContainer(DockerImageName.parse(config.imageName), config.fixedExposedPort, launchMode.getLaunchMode() == LaunchMode.DEVELOPMENT ? config.serviceName : null, useSharedNetwork);
LOGGER.debug(String.format("TrustyService DataSource Kind: %s", devServicesConfig.getDataSourceKind()));
LOGGER.debug(String.format("TrustyService DataSource Username: %s", devServicesConfig.getDataSourceUserName()));
LOGGER.debug(String.format("TrustyService DataSource Password: %s", devServicesConfig.getDataSourcePassword()));
LOGGER.debug(String.format("TrustyService DataSource URL: %s", devServicesConfig.getDataSourceUrl()));
LOGGER.debug(String.format("TrustyService Kafka Bootstrap Server: %s", devServicesConfig.getKafkaBootstrapServer()));
LOGGER.debug(String.format("TrustyService Hibernate ORM Database Generation: %s", devServicesConfig.getHibernateOrmDatabaseGeneration()));
// Environment variables used by kogito-images when launching the TrustyService container
container.addEnv("SCRIPT_DEBUG", "false");
container.addEnv("EXPLAINABILITY_ENABLED", "false");
// Environment variables used by TrustyService to integrate with other services
container.addEnv(QuarkusDataSourceDbKind.getEnvironmentVariableName(), devServicesConfig.getDataSourceKind());
container.addEnv(QuarkusDataSourceUserName.getEnvironmentVariableName(), devServicesConfig.getDataSourceUserName());
container.addEnv(QuarkusDataSourcePassword.getEnvironmentVariableName(), devServicesConfig.getDataSourcePassword());
container.addEnv(QuarkusDataSourceJdbcUrl.getEnvironmentVariableName(), devServicesConfig.getDataSourceUrl());
container.addEnv(KafkaBootstrapServers.getEnvironmentVariableName(), devServicesConfig.getKafkaBootstrapServer());
container.addEnv(HibernateOrmDatabaseGeneration.getEnvironmentVariableName(), devServicesConfig.getHibernateOrmDatabaseGeneration());
container.start();
return new TrustyServiceInstance(container.getUrl(), container::close);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
};
return maybeContainerAddress.map(containerAddress -> new TrustyServiceInstance(containerAddress.getUrl(), null)).orElseGet(trustyServiceSupplier);
}
Aggregations