use of org.eclipse.jkube.kit.build.service.docker.DockerServiceHub in project jkube by eclipse.
the class DockerImageWatcher method watch.
@Override
public void watch(List<ImageConfiguration> configs, String namespace, final Collection<HasMetadata> resources, PlatformMode mode) {
WatchContext watchContext = getContext().getWatchContext();
watchContext = watchContext.toBuilder().imageCustomizer(this::buildImage).containerRestarter(imageWatcher -> restartContainer(imageWatcher, resources)).containerCommandExecutor(command -> executeCommandInPod(command, resources)).containerCopyTask(f -> copyFileToPod(f, resources)).build();
DockerServiceHub hub = getContext().getJKubeServiceHub().getDockerServiceHub();
try {
hub.getWatchService().watch(watchContext, getContext().getBuildContext(), configs);
} catch (Exception ex) {
throw new RuntimeException("Error while watching", ex);
}
}
use of org.eclipse.jkube.kit.build.service.docker.DockerServiceHub in project jkube by eclipse.
the class Main method main.
public static void main(String[] args) {
final KitLogger kitLogger = new KitLogger.StdoutLogger();
kitLogger.info("Initiating default JKube configuration and required services...");
kitLogger.info(" - Creating Docker Service Hub");
final DockerServiceHub dockerServiceHub = DockerServiceHub.newInstance(kitLogger);
kitLogger.info(" - Creating Docker Build Service Configuration");
final BuildServiceConfig dockerBuildServiceConfig = BuildServiceConfig.builder().build();
kitLogger.info(" - Creating configuration for JKube");
kitLogger.info(" - Current working directory is: %s", getProjectDir().toFile().toString());
final JKubeConfiguration configuration = JKubeConfiguration.builder().project(JavaProject.builder().baseDirectory(getProjectDir().toFile()).build()).outputDirectory("target").sourceDirectory(getProjectDir().toFile().getAbsolutePath()).build();
JKubeServiceHub.JKubeServiceHubBuilder buildBuilder = JKubeServiceHub.builder().log(kitLogger).configuration(configuration).platformMode(RuntimeMode.KUBERNETES).dockerServiceHub(dockerServiceHub).buildServiceConfig(dockerBuildServiceConfig);
try (JKubeServiceHub jKubeServiceHub = buildBuilder.build()) {
jKubeServiceHub.getBuildService().build(new DynamicDockerfileGenerator(kitLogger, getProjectDir(), IMAGE_NAME).generateImageConfiguration());
final String imageId = jKubeServiceHub.getDockerServiceHub().getDockerAccess().getImageId(IMAGE_NAME);
kitLogger.info("Docker image built successfully (%s)!", imageId);
System.exit(0);
} catch (Exception ex) {
ex.printStackTrace();
kitLogger.error("Error occurred: '%s'", ex.getMessage());
}
}
Aggregations