From 565540b6020c8236c0ed462473f8569f29eb7a32 Mon Sep 17 00:00:00 2001 From: Reto Weiss Date: Fri, 1 Sep 2023 15:06:24 +0200 Subject: [PATCH 1/8] Initial version copied from ivy-cloud repo --- README.md | 8 +- .../README.md | 4 +- .../pom.xml | 4 +- .../product.json | 0 .../zip.xml | 0 docker-connector/.classpath | 33 +++++ docker-connector/.gitignore | 19 +++ docker-connector/.project | 49 ++++++++ docker-connector/.settings/.jsdtscope | 12 ++ .../.settings/ch.ivyteam.ivy.designer.prefs | 5 + .../.settings/org.eclipse.jdt.core.prefs | 10 ++ .../org.eclipse.wst.common.component | 11 ++ ...se.wst.common.project.facet.core.prefs.xml | 7 ++ ....eclipse.wst.common.project.facet.core.xml | 8 ++ .../.settings/org.eclipse.wst.css.core.prefs | 2 + ...rg.eclipse.wst.jsdt.ui.superType.container | 1 + .../org.eclipse.wst.jsdt.ui.superType.name | 1 + docker-connector/config/custom-fields.yaml | 20 +++ docker-connector/config/databases.yaml | 1 + docker-connector/config/overrides.any | 1 + docker-connector/config/persistence.xml | 2 + docker-connector/config/rest-clients.yaml | 1 + docker-connector/config/roles.xml | 4 + docker-connector/config/users.xml | 2 + docker-connector/config/variables.yaml | 20 +++ .../config/webservice-clients.yaml | 1 + .../docker/connector/Data.ivyClass | 2 + docker-connector/pom.xml | 31 +++++ .../docker/AbstractResultCallback.java | 68 ++++++++++ .../docker/ExecuteResultCallback.java | 13 ++ .../connector/docker/IvyDockerClient.java | 117 ++++++++++++++++++ .../connector/docker/PullResultCallback.java | 12 ++ pom.xml | 8 +- 33 files changed, 465 insertions(+), 12 deletions(-) rename {MY-PRODUCT-NAME-product => docker-connector-product}/README.md (85%) rename {MY-PRODUCT-NAME-product => docker-connector-product}/pom.xml (94%) rename {MY-PRODUCT-NAME-product => docker-connector-product}/product.json (100%) rename {MY-PRODUCT-NAME-product => docker-connector-product}/zip.xml (100%) create mode 100644 docker-connector/.classpath create mode 100644 docker-connector/.gitignore create mode 100644 docker-connector/.project create mode 100644 docker-connector/.settings/.jsdtscope create mode 100644 docker-connector/.settings/ch.ivyteam.ivy.designer.prefs create mode 100644 docker-connector/.settings/org.eclipse.jdt.core.prefs create mode 100644 docker-connector/.settings/org.eclipse.wst.common.component create mode 100644 docker-connector/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml create mode 100644 docker-connector/.settings/org.eclipse.wst.common.project.facet.core.xml create mode 100644 docker-connector/.settings/org.eclipse.wst.css.core.prefs create mode 100644 docker-connector/.settings/org.eclipse.wst.jsdt.ui.superType.container create mode 100644 docker-connector/.settings/org.eclipse.wst.jsdt.ui.superType.name create mode 100644 docker-connector/config/custom-fields.yaml create mode 100644 docker-connector/config/databases.yaml create mode 100644 docker-connector/config/overrides.any create mode 100644 docker-connector/config/persistence.xml create mode 100644 docker-connector/config/rest-clients.yaml create mode 100644 docker-connector/config/roles.xml create mode 100644 docker-connector/config/users.xml create mode 100644 docker-connector/config/variables.yaml create mode 100644 docker-connector/config/webservice-clients.yaml create mode 100644 docker-connector/dataclasses/docker/connector/Data.ivyClass create mode 100644 docker-connector/pom.xml create mode 100644 docker-connector/src/com/axonivy/connector/docker/AbstractResultCallback.java create mode 100644 docker-connector/src/com/axonivy/connector/docker/ExecuteResultCallback.java create mode 100644 docker-connector/src/com/axonivy/connector/docker/IvyDockerClient.java create mode 100644 docker-connector/src/com/axonivy/connector/docker/PullResultCallback.java diff --git a/README.md b/README.md index 0f94020..083112b 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -# MY-PRODUCT-NAME +# Docker Connector -[![CI Build](https://github.com/axonivy-market/REPO-NAME/actions/workflows/ci.yml/badge.svg)](https://github.com/axonivy-market/REPO-NAME/actions/workflows/ci.yml) +[![CI Build](https://github.com/axonivy-market/docker-connector/actions/workflows/ci.yml/badge.svg)](https://github.com/axonivy-market/docker-connector/actions/workflows/ci.yml) -"YOUR SHORT DESCRIPTION GOES HERE" +Connector to create/start/stop/delete Docker containers -Read our [documentation](MY-PRODUCT-NAME-product/README.md). +Read our [documentation](docker-connector-product/README.md). diff --git a/MY-PRODUCT-NAME-product/README.md b/docker-connector-product/README.md similarity index 85% rename from MY-PRODUCT-NAME-product/README.md rename to docker-connector-product/README.md index ee9062a..ddf38c0 100644 --- a/MY-PRODUCT-NAME-product/README.md +++ b/docker-connector-product/README.md @@ -1,4 +1,4 @@ -# MY-PRODUCT-NAME +# Docker Connector YOUR DESCRIPTION GOES HERE @@ -12,4 +12,4 @@ YOUR SETUP DESCRIPTION GOES HERE ``` @variables.yaml@ -``` \ No newline at end of file +``` diff --git a/MY-PRODUCT-NAME-product/pom.xml b/docker-connector-product/pom.xml similarity index 94% rename from MY-PRODUCT-NAME-product/pom.xml rename to docker-connector-product/pom.xml index dd59011..f7fd1d7 100644 --- a/MY-PRODUCT-NAME-product/pom.xml +++ b/docker-connector-product/pom.xml @@ -1,12 +1,12 @@ 4.0.0 com.axonivy.market - MY-PRODUCT-NAME-product + docker-connector-product 10.0.0-SNAPSHOT pom - ../MY-PRODUCT-NAME/config/variables.yaml + ../docker-connector/config/variables.yaml diff --git a/MY-PRODUCT-NAME-product/product.json b/docker-connector-product/product.json similarity index 100% rename from MY-PRODUCT-NAME-product/product.json rename to docker-connector-product/product.json diff --git a/MY-PRODUCT-NAME-product/zip.xml b/docker-connector-product/zip.xml similarity index 100% rename from MY-PRODUCT-NAME-product/zip.xml rename to docker-connector-product/zip.xml diff --git a/docker-connector/.classpath b/docker-connector/.classpath new file mode 100644 index 0000000..aa20b3e --- /dev/null +++ b/docker-connector/.classpath @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docker-connector/.gitignore b/docker-connector/.gitignore new file mode 100644 index 0000000..1b2547b --- /dev/null +++ b/docker-connector/.gitignore @@ -0,0 +1,19 @@ +# general +Thumbs.db +.DS_Store +*~ +*.log + +# java +*.class +hs_err_pid* + +# maven +target/ +lib/mvn-deps/ + +# ivy +classes/ +src_dataClasses/ +src_wsproc/ +logs/ diff --git a/docker-connector/.project b/docker-connector/.project new file mode 100644 index 0000000..a3551fe --- /dev/null +++ b/docker-connector/.project @@ -0,0 +1,49 @@ + + + docker-connector + + + + + + ch.ivyteam.ivy.designer.dataClasses.ui.ivyDataClassBuilder + + + + + ch.ivyteam.ivy.designer.process.ui.ivyWebServiceProcessClassBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + ch.ivyteam.ivy.designer.ide.ivyModelValidationBuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + ch.ivyteam.ivy.project.IvyProjectNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.jem.beaninfo.BeanInfoNature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.wst.jsdt.core.jsNature + + diff --git a/docker-connector/.settings/.jsdtscope b/docker-connector/.settings/.jsdtscope new file mode 100644 index 0000000..cf5ec79 --- /dev/null +++ b/docker-connector/.settings/.jsdtscope @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/docker-connector/.settings/ch.ivyteam.ivy.designer.prefs b/docker-connector/.settings/ch.ivyteam.ivy.designer.prefs new file mode 100644 index 0000000..95170c5 --- /dev/null +++ b/docker-connector/.settings/ch.ivyteam.ivy.designer.prefs @@ -0,0 +1,5 @@ +ch.ivyteam.ivy.designer.preferences.DataClassPreferencePage\:DEFAULT_DATA_CLASS=docker.connector.Data +ch.ivyteam.ivy.designer.preferences.DataClassPreferencePage\:DEFAULT_NAMESPACE=docker.connector +ch.ivyteam.ivy.project.preferences\:PRIMEFACES_VERSION=11 +ch.ivyteam.ivy.project.preferences\:PROJECT_VERSION=100000 +eclipse.preferences.version=1 diff --git a/docker-connector/.settings/org.eclipse.jdt.core.prefs b/docker-connector/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..f78f7f7 --- /dev/null +++ b/docker-connector/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,10 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/docker-connector/.settings/org.eclipse.wst.common.component b/docker-connector/.settings/org.eclipse.wst.common.component new file mode 100644 index 0000000..cd7037c --- /dev/null +++ b/docker-connector/.settings/org.eclipse.wst.common.component @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/docker-connector/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml b/docker-connector/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml new file mode 100644 index 0000000..0d46547 --- /dev/null +++ b/docker-connector/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/docker-connector/.settings/org.eclipse.wst.common.project.facet.core.xml b/docker-connector/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 0000000..c2098f9 --- /dev/null +++ b/docker-connector/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docker-connector/.settings/org.eclipse.wst.css.core.prefs b/docker-connector/.settings/org.eclipse.wst.css.core.prefs new file mode 100644 index 0000000..96b96cd --- /dev/null +++ b/docker-connector/.settings/org.eclipse.wst.css.core.prefs @@ -0,0 +1,2 @@ +css-profile/=org.eclipse.wst.css.core.cssprofile.css3 +eclipse.preferences.version=1 diff --git a/docker-connector/.settings/org.eclipse.wst.jsdt.ui.superType.container b/docker-connector/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 0000000..3bd5d0a --- /dev/null +++ b/docker-connector/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/docker-connector/.settings/org.eclipse.wst.jsdt.ui.superType.name b/docker-connector/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 0000000..05bd71b --- /dev/null +++ b/docker-connector/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/docker-connector/config/custom-fields.yaml b/docker-connector/config/custom-fields.yaml new file mode 100644 index 0000000..aa19ae0 --- /dev/null +++ b/docker-connector/config/custom-fields.yaml @@ -0,0 +1,20 @@ +# == Custom Fields Information == +# +# You can define here your project custom fields. +# Have a look at our documentation for more information. +# +CustomFields: +# Tasks: +# MyTaskCustomField: +# Label: My task custom field +# Description: This new task custom field can be used to ... +# Type: STRING +# Cases: +# MyCaseCustomField: +# Label: My case custom field +# Description: This new case custom field can be used to ... +# Type: STRING +# Starts: +# MyStartCustomField: +# Label: My start custom field +# Description: This new start custom field can be used to ... diff --git a/docker-connector/config/databases.yaml b/docker-connector/config/databases.yaml new file mode 100644 index 0000000..247b128 --- /dev/null +++ b/docker-connector/config/databases.yaml @@ -0,0 +1 @@ +Databases: diff --git a/docker-connector/config/overrides.any b/docker-connector/config/overrides.any new file mode 100644 index 0000000..f59ec20 --- /dev/null +++ b/docker-connector/config/overrides.any @@ -0,0 +1 @@ +* \ No newline at end of file diff --git a/docker-connector/config/persistence.xml b/docker-connector/config/persistence.xml new file mode 100644 index 0000000..d6b96d7 --- /dev/null +++ b/docker-connector/config/persistence.xml @@ -0,0 +1,2 @@ + + diff --git a/docker-connector/config/rest-clients.yaml b/docker-connector/config/rest-clients.yaml new file mode 100644 index 0000000..8e85296 --- /dev/null +++ b/docker-connector/config/rest-clients.yaml @@ -0,0 +1 @@ +RestClients: diff --git a/docker-connector/config/roles.xml b/docker-connector/config/roles.xml new file mode 100644 index 0000000..59892fe --- /dev/null +++ b/docker-connector/config/roles.xml @@ -0,0 +1,4 @@ + + + Everybody + diff --git a/docker-connector/config/users.xml b/docker-connector/config/users.xml new file mode 100644 index 0000000..51a6906 --- /dev/null +++ b/docker-connector/config/users.xml @@ -0,0 +1,2 @@ + + diff --git a/docker-connector/config/variables.yaml b/docker-connector/config/variables.yaml new file mode 100644 index 0000000..c4ba134 --- /dev/null +++ b/docker-connector/config/variables.yaml @@ -0,0 +1,20 @@ +# == Variables == +# +# You can define here your project Variables. +# If you want to define/override a Variable for a specific Environment, +# add an additional ‘variables.yaml’ file in a subdirectory in the ‘Config’ folder: +# '/Config/_/variables.yaml +# +Variables: +# myVariable: value + Docker: + # URL to communicate with the docker daemon + # Windows Pipe: + # npipe:////./pipe/dockerDesktopLinuxEngine + # Linux: + # unix:///var/run/docker.sock + # TCP (Outside container): + # tcp://localhost:2375 + # TCP (Inside a container): + # tcp://host.docker.internal:2375 + URL: "tcp://localhost:2375/" \ No newline at end of file diff --git a/docker-connector/config/webservice-clients.yaml b/docker-connector/config/webservice-clients.yaml new file mode 100644 index 0000000..060b018 --- /dev/null +++ b/docker-connector/config/webservice-clients.yaml @@ -0,0 +1 @@ +WebServiceClients: diff --git a/docker-connector/dataclasses/docker/connector/Data.ivyClass b/docker-connector/dataclasses/docker/connector/Data.ivyClass new file mode 100644 index 0000000..caff849 --- /dev/null +++ b/docker-connector/dataclasses/docker/connector/Data.ivyClass @@ -0,0 +1,2 @@ +Data #class +docker.connector #namespace diff --git a/docker-connector/pom.xml b/docker-connector/pom.xml new file mode 100644 index 0000000..7815255 --- /dev/null +++ b/docker-connector/pom.xml @@ -0,0 +1,31 @@ + + + 4.0.0 + com.axonivy.market + docker-connector + 10.0.0-SNAPSHOT + iar + + + + com.axonivy.ivy.ci + project-build-plugin + 10.0.6 + true + + + + + + com.github.docker-java + docker-java-core + 3.3.3 + + + com.github.docker-java + docker-java-transport-httpclient5 + 3.3.3 + + + diff --git a/docker-connector/src/com/axonivy/connector/docker/AbstractResultCallback.java b/docker-connector/src/com/axonivy/connector/docker/AbstractResultCallback.java new file mode 100644 index 0000000..04d3288 --- /dev/null +++ b/docker-connector/src/com/axonivy/connector/docker/AbstractResultCallback.java @@ -0,0 +1,68 @@ +package com.axonivy.connector.docker; + +import java.io.Closeable; +import java.io.IOException; + +import com.github.dockerjava.api.async.ResultCallback; + +abstract class AbstractResultCallback implements ResultCallback { + + enum State { + CREATED, + RUNNING, + ERROR, + COMPLETE, + + } + private AbstractResultCallback.State state = State.CREATED; + private Closeable closeable; + protected StringBuilder builder = new StringBuilder(); + private Throwable error = null; + + @Override + public synchronized void close() { + try { + this.closeable.close(); + } catch (IOException ex) { + error = ex; + } + } + + @Override + public synchronized void onStart(Closeable c) { + this.closeable = c; + this.state = State.RUNNING; + } + + @Override + public synchronized void onError(Throwable e) { + this.state = State.ERROR; + this.error = e; + close(); + notifyAll(); + } + + @Override + public synchronized void onComplete() { + this.state = State.COMPLETE; + close(); + notifyAll(); + } + + public synchronized String await() { + while (state == State.RUNNING || state == State.CREATED) { + try { + wait(); + } catch (InterruptedException ex) { + throw new RuntimeException(ex); + } + } + if (error != null) { + if (error instanceof RuntimeException re) { + throw re; + } + throw new RuntimeException(error); + } + return builder.toString(); + } +} \ No newline at end of file diff --git a/docker-connector/src/com/axonivy/connector/docker/ExecuteResultCallback.java b/docker-connector/src/com/axonivy/connector/docker/ExecuteResultCallback.java new file mode 100644 index 0000000..8937cad --- /dev/null +++ b/docker-connector/src/com/axonivy/connector/docker/ExecuteResultCallback.java @@ -0,0 +1,13 @@ +package com.axonivy.connector.docker; + +import java.nio.charset.StandardCharsets; + +import com.github.dockerjava.api.model.Frame; + +class ExecuteResultCallback extends AbstractResultCallback { + + @Override + public synchronized void onNext(Frame frame) { + builder.append(new String(frame.getPayload(), StandardCharsets.UTF_8)); + } +} \ No newline at end of file diff --git a/docker-connector/src/com/axonivy/connector/docker/IvyDockerClient.java b/docker-connector/src/com/axonivy/connector/docker/IvyDockerClient.java new file mode 100644 index 0000000..34b1107 --- /dev/null +++ b/docker-connector/src/com/axonivy/connector/docker/IvyDockerClient.java @@ -0,0 +1,117 @@ +package com.axonivy.connector.docker; + +import java.nio.file.Path; +import java.time.Duration; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +import com.github.dockerjava.api.DockerClient; +import com.github.dockerjava.api.command.CreateContainerCmd; +import com.github.dockerjava.api.command.ListContainersCmd; +import com.github.dockerjava.api.model.Network; +import com.github.dockerjava.core.DefaultDockerClientConfig; +import com.github.dockerjava.core.DockerClientImpl; +import com.github.dockerjava.httpclient5.ApacheDockerHttpClient; + +import ch.ivyteam.ivy.environment.Ivy; + +public class IvyDockerClient { + + private static final IvyDockerClient INSTANCE = new IvyDockerClient(); + private DockerClient client; + + private IvyDockerClient() { + client = createDockerClient(); + } + + public static IvyDockerClient instance() { + return INSTANCE; + } + + private static DockerClient createDockerClient() { + var dockerUrl = Ivy.var().get("Docker.URL"); + var config = DefaultDockerClientConfig.createDefaultConfigBuilder() + .withDockerHost(dockerUrl) +// .withDockerTlsVerify(true) +// .withDockerCertPath("C:\\Users\\rwei.ZUGPCRWEI2\\AppData\\Local\\Docker\\pki") + .build(); + + var httpClient = new ApacheDockerHttpClient.Builder() + .dockerHost(config.getDockerHost()) +// .sslConfig(config.getSSLConfig()) + .maxConnections(100) + .connectionTimeout(Duration.ofSeconds(30)) + .responseTimeout(Duration.ofSeconds(45)) + .build(); + + var docker = DockerClientImpl.getInstance(config, httpClient); + return docker; + } + + public CreateContainerCmd createContainerCmd(String image) { + var resp = client.listImagesCmd().withFilter("reference", List.of(image)).exec(); + if (resp.isEmpty()) { + var result = new PullResultCallback(); + client.pullImageCmd(image).exec(result); + result.await(); + } + return client.createContainerCmd(image); + } + + public ListContainersCmd listContainersCmd() { + return client.listContainersCmd(); + } + + public void stopContainer(String id) { + client.stopContainerCmd(id).exec(); + Ivy.log().info("Container "+id+" stopped"); + } + + public void removeContainer(String id) { + client.removeContainerCmd(id).exec(); + Ivy.log().info("Container "+id+" removed"); + } + + public void startContainer(String id) { + client.startContainerCmd(id).exec(); + Ivy.log().info("Container "+id+" started"); + } + + public void executeInContainer(String id, String... command) { + var cmd = client.execCreateCmd(id) + .withCmd(command) + .withAttachStderr(true) + .withAttachStdout(true) + .withTty(true) + .exec(); + var res = new ExecuteResultCallback(); + client.execStartCmd(cmd.getId()) + .withDetach(false) + .withTty(true) + .exec(res); + var cmdStr = Arrays.stream(command).collect(Collectors.joining(" ")); + Ivy.log().info("Execute '"+cmdStr+"' in container "+id+":\n" + res.await()); + } + + public String createNetwork(String name) { + return client.createNetworkCmd().withName(name).exec().getId(); + } + + public Optional findNetwork(String name) { + return client.listNetworksCmd().withFilter("name", List.of(name)).exec().stream().findAny(); + } + + public void connectContainerToNetwork(String id, String networkId) { + client.connectToNetworkCmd().withContainerId(id).withNetworkId(networkId).exec(); + } + + public void copyToContainer(Path hostPath, String containerId, String containerPath) { + client.copyArchiveToContainerCmd(containerId) + .withHostResource(hostPath.toString()) + .withRemotePath(containerPath) + .exec(); + } + +} diff --git a/docker-connector/src/com/axonivy/connector/docker/PullResultCallback.java b/docker-connector/src/com/axonivy/connector/docker/PullResultCallback.java new file mode 100644 index 0000000..2e9d1e1 --- /dev/null +++ b/docker-connector/src/com/axonivy/connector/docker/PullResultCallback.java @@ -0,0 +1,12 @@ +package com.axonivy.connector.docker; + +import com.github.dockerjava.api.model.PullResponseItem; + +class PullResultCallback extends AbstractResultCallback{ + + @Override + public void onNext(PullResponseItem pullItem) { + builder.append(pullItem.getStatus()); + } + +} diff --git a/pom.xml b/pom.xml index 517336b..03b4111 100644 --- a/pom.xml +++ b/pom.xml @@ -1,15 +1,15 @@ 4.0.0 com.axonivy.market - my-product - my-product-modules + docker-connector + docker-connector-modules 10.0.0-SNAPSHOT pom ${project.name} - ${project.name}-demo - ${project.name}-test + ${project.name}-product From 34d278fa13725af98eae3e72ac014cea9e310edf Mon Sep 17 00:00:00 2001 From: Reto Weiss Date: Fri, 1 Sep 2023 16:02:40 +0200 Subject: [PATCH 2/8] Add demo project --- docker-connector-demo/.classpath | 33 +++ docker-connector-demo/.gitignore | 19 ++ docker-connector-demo/.project | 49 ++++ docker-connector-demo/.settings/.jsdtscope | 12 + .../.settings/ch.ivyteam.ivy.designer.prefs | 5 + .../.settings/org.eclipse.jdt.core.prefs | 10 + .../org.eclipse.wst.common.component | 11 + ...se.wst.common.project.facet.core.prefs.xml | 7 + ....eclipse.wst.common.project.facet.core.xml | 8 + .../.settings/org.eclipse.wst.css.core.prefs | 2 + ...rg.eclipse.wst.jsdt.ui.superType.container | 1 + .../org.eclipse.wst.jsdt.ui.superType.name | 1 + .../config/custom-fields.yaml | 20 ++ docker-connector-demo/config/databases.yaml | 1 + docker-connector-demo/config/overrides.any | 1 + docker-connector-demo/config/persistence.xml | 2 + .../config/rest-clients.yaml | 1 + docker-connector-demo/config/roles.xml | 4 + docker-connector-demo/config/users.xml | 2 + docker-connector-demo/config/variables.yaml | 9 + .../config/webservice-clients.yaml | 1 + .../docker/connector/demo/Data.ivyClass | 4 + docker-connector-demo/pom.xml | 27 +++ .../processes/dockerDemo.p.json | 140 ++++++++++++ .../demo/ShowEngine/ShowEngine.rddescriptor | 7 + .../demo/ShowEngine/ShowEngine.xhtml | 28 +++ .../demo/ShowEngine/ShowEngineData.ivyClass | 2 + .../demo/ShowEngine/ShowEngineProcess.p.json | 44 ++++ .../layouts/frame-10-full-width.xhtml | 60 +++++ .../layouts/includes/exception-details.xhtml | 109 +++++++++ .../layouts/includes/exception.xhtml | 47 ++++ .../webContent/layouts/includes/footer.xhtml | 18 ++ .../layouts/includes/progress-loader.xhtml | 15 ++ docker-connector-product/product.json | 8 +- .../axonivy/connector/docker/Data.ivyClass | 10 + .../connector/docker/PortBinding.ivyClass | 6 + docker-connector/processes/docker.p.json | 209 ++++++++++++++++++ pom.xml | 4 +- 38 files changed, 931 insertions(+), 6 deletions(-) create mode 100644 docker-connector-demo/.classpath create mode 100644 docker-connector-demo/.gitignore create mode 100644 docker-connector-demo/.project create mode 100644 docker-connector-demo/.settings/.jsdtscope create mode 100644 docker-connector-demo/.settings/ch.ivyteam.ivy.designer.prefs create mode 100644 docker-connector-demo/.settings/org.eclipse.jdt.core.prefs create mode 100644 docker-connector-demo/.settings/org.eclipse.wst.common.component create mode 100644 docker-connector-demo/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml create mode 100644 docker-connector-demo/.settings/org.eclipse.wst.common.project.facet.core.xml create mode 100644 docker-connector-demo/.settings/org.eclipse.wst.css.core.prefs create mode 100644 docker-connector-demo/.settings/org.eclipse.wst.jsdt.ui.superType.container create mode 100644 docker-connector-demo/.settings/org.eclipse.wst.jsdt.ui.superType.name create mode 100644 docker-connector-demo/config/custom-fields.yaml create mode 100644 docker-connector-demo/config/databases.yaml create mode 100644 docker-connector-demo/config/overrides.any create mode 100644 docker-connector-demo/config/persistence.xml create mode 100644 docker-connector-demo/config/rest-clients.yaml create mode 100644 docker-connector-demo/config/roles.xml create mode 100644 docker-connector-demo/config/users.xml create mode 100644 docker-connector-demo/config/variables.yaml create mode 100644 docker-connector-demo/config/webservice-clients.yaml create mode 100644 docker-connector-demo/dataclasses/com/axonivy/market/docker/connector/demo/Data.ivyClass create mode 100644 docker-connector-demo/pom.xml create mode 100644 docker-connector-demo/processes/dockerDemo.p.json create mode 100644 docker-connector-demo/src_hd/com/axonivy/market/docker/connector/demo/ShowEngine/ShowEngine.rddescriptor create mode 100644 docker-connector-demo/src_hd/com/axonivy/market/docker/connector/demo/ShowEngine/ShowEngine.xhtml create mode 100644 docker-connector-demo/src_hd/com/axonivy/market/docker/connector/demo/ShowEngine/ShowEngineData.ivyClass create mode 100644 docker-connector-demo/src_hd/com/axonivy/market/docker/connector/demo/ShowEngine/ShowEngineProcess.p.json create mode 100644 docker-connector-demo/webContent/layouts/frame-10-full-width.xhtml create mode 100644 docker-connector-demo/webContent/layouts/includes/exception-details.xhtml create mode 100644 docker-connector-demo/webContent/layouts/includes/exception.xhtml create mode 100644 docker-connector-demo/webContent/layouts/includes/footer.xhtml create mode 100644 docker-connector-demo/webContent/layouts/includes/progress-loader.xhtml create mode 100644 docker-connector/dataclasses/com/axonivy/connector/docker/Data.ivyClass create mode 100644 docker-connector/dataclasses/com/axonivy/connector/docker/PortBinding.ivyClass create mode 100644 docker-connector/processes/docker.p.json diff --git a/docker-connector-demo/.classpath b/docker-connector-demo/.classpath new file mode 100644 index 0000000..aa20b3e --- /dev/null +++ b/docker-connector-demo/.classpath @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docker-connector-demo/.gitignore b/docker-connector-demo/.gitignore new file mode 100644 index 0000000..1b2547b --- /dev/null +++ b/docker-connector-demo/.gitignore @@ -0,0 +1,19 @@ +# general +Thumbs.db +.DS_Store +*~ +*.log + +# java +*.class +hs_err_pid* + +# maven +target/ +lib/mvn-deps/ + +# ivy +classes/ +src_dataClasses/ +src_wsproc/ +logs/ diff --git a/docker-connector-demo/.project b/docker-connector-demo/.project new file mode 100644 index 0000000..bbd4f3a --- /dev/null +++ b/docker-connector-demo/.project @@ -0,0 +1,49 @@ + + + docker-connector-demo + + + + + + ch.ivyteam.ivy.designer.dataClasses.ui.ivyDataClassBuilder + + + + + ch.ivyteam.ivy.designer.process.ui.ivyWebServiceProcessClassBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + ch.ivyteam.ivy.designer.ide.ivyModelValidationBuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + ch.ivyteam.ivy.project.IvyProjectNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.jem.beaninfo.BeanInfoNature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.wst.jsdt.core.jsNature + + diff --git a/docker-connector-demo/.settings/.jsdtscope b/docker-connector-demo/.settings/.jsdtscope new file mode 100644 index 0000000..cf5ec79 --- /dev/null +++ b/docker-connector-demo/.settings/.jsdtscope @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/docker-connector-demo/.settings/ch.ivyteam.ivy.designer.prefs b/docker-connector-demo/.settings/ch.ivyteam.ivy.designer.prefs new file mode 100644 index 0000000..227bf13 --- /dev/null +++ b/docker-connector-demo/.settings/ch.ivyteam.ivy.designer.prefs @@ -0,0 +1,5 @@ +ch.ivyteam.ivy.designer.preferences.DataClassPreferencePage\:DEFAULT_DATA_CLASS=com.axonivy.market.docker.connector.demo.Data +ch.ivyteam.ivy.designer.preferences.DataClassPreferencePage\:DEFAULT_NAMESPACE=com.axonivy.market.docker.connector.demo +ch.ivyteam.ivy.project.preferences\:PRIMEFACES_VERSION=11 +ch.ivyteam.ivy.project.preferences\:PROJECT_VERSION=100000 +eclipse.preferences.version=1 diff --git a/docker-connector-demo/.settings/org.eclipse.jdt.core.prefs b/docker-connector-demo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..f78f7f7 --- /dev/null +++ b/docker-connector-demo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,10 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/docker-connector-demo/.settings/org.eclipse.wst.common.component b/docker-connector-demo/.settings/org.eclipse.wst.common.component new file mode 100644 index 0000000..4b077bc --- /dev/null +++ b/docker-connector-demo/.settings/org.eclipse.wst.common.component @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/docker-connector-demo/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml b/docker-connector-demo/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml new file mode 100644 index 0000000..0d46547 --- /dev/null +++ b/docker-connector-demo/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/docker-connector-demo/.settings/org.eclipse.wst.common.project.facet.core.xml b/docker-connector-demo/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 0000000..c2098f9 --- /dev/null +++ b/docker-connector-demo/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docker-connector-demo/.settings/org.eclipse.wst.css.core.prefs b/docker-connector-demo/.settings/org.eclipse.wst.css.core.prefs new file mode 100644 index 0000000..96b96cd --- /dev/null +++ b/docker-connector-demo/.settings/org.eclipse.wst.css.core.prefs @@ -0,0 +1,2 @@ +css-profile/=org.eclipse.wst.css.core.cssprofile.css3 +eclipse.preferences.version=1 diff --git a/docker-connector-demo/.settings/org.eclipse.wst.jsdt.ui.superType.container b/docker-connector-demo/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 0000000..3bd5d0a --- /dev/null +++ b/docker-connector-demo/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/docker-connector-demo/.settings/org.eclipse.wst.jsdt.ui.superType.name b/docker-connector-demo/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 0000000..05bd71b --- /dev/null +++ b/docker-connector-demo/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/docker-connector-demo/config/custom-fields.yaml b/docker-connector-demo/config/custom-fields.yaml new file mode 100644 index 0000000..aa19ae0 --- /dev/null +++ b/docker-connector-demo/config/custom-fields.yaml @@ -0,0 +1,20 @@ +# == Custom Fields Information == +# +# You can define here your project custom fields. +# Have a look at our documentation for more information. +# +CustomFields: +# Tasks: +# MyTaskCustomField: +# Label: My task custom field +# Description: This new task custom field can be used to ... +# Type: STRING +# Cases: +# MyCaseCustomField: +# Label: My case custom field +# Description: This new case custom field can be used to ... +# Type: STRING +# Starts: +# MyStartCustomField: +# Label: My start custom field +# Description: This new start custom field can be used to ... diff --git a/docker-connector-demo/config/databases.yaml b/docker-connector-demo/config/databases.yaml new file mode 100644 index 0000000..247b128 --- /dev/null +++ b/docker-connector-demo/config/databases.yaml @@ -0,0 +1 @@ +Databases: diff --git a/docker-connector-demo/config/overrides.any b/docker-connector-demo/config/overrides.any new file mode 100644 index 0000000..f59ec20 --- /dev/null +++ b/docker-connector-demo/config/overrides.any @@ -0,0 +1 @@ +* \ No newline at end of file diff --git a/docker-connector-demo/config/persistence.xml b/docker-connector-demo/config/persistence.xml new file mode 100644 index 0000000..d6b96d7 --- /dev/null +++ b/docker-connector-demo/config/persistence.xml @@ -0,0 +1,2 @@ + + diff --git a/docker-connector-demo/config/rest-clients.yaml b/docker-connector-demo/config/rest-clients.yaml new file mode 100644 index 0000000..8e85296 --- /dev/null +++ b/docker-connector-demo/config/rest-clients.yaml @@ -0,0 +1 @@ +RestClients: diff --git a/docker-connector-demo/config/roles.xml b/docker-connector-demo/config/roles.xml new file mode 100644 index 0000000..59892fe --- /dev/null +++ b/docker-connector-demo/config/roles.xml @@ -0,0 +1,4 @@ + + + Everybody + diff --git a/docker-connector-demo/config/users.xml b/docker-connector-demo/config/users.xml new file mode 100644 index 0000000..51a6906 --- /dev/null +++ b/docker-connector-demo/config/users.xml @@ -0,0 +1,2 @@ + + diff --git a/docker-connector-demo/config/variables.yaml b/docker-connector-demo/config/variables.yaml new file mode 100644 index 0000000..64c8fa0 --- /dev/null +++ b/docker-connector-demo/config/variables.yaml @@ -0,0 +1,9 @@ +# == Variables == +# +# You can define here your project Variables. +# If you want to define/override a Variable for a specific Environment, +# add an additional ‘variables.yaml’ file in a subdirectory in the ‘Config’ folder: +# '/Config/_/variables.yaml +# +Variables: +# myVariable: value diff --git a/docker-connector-demo/config/webservice-clients.yaml b/docker-connector-demo/config/webservice-clients.yaml new file mode 100644 index 0000000..060b018 --- /dev/null +++ b/docker-connector-demo/config/webservice-clients.yaml @@ -0,0 +1 @@ +WebServiceClients: diff --git a/docker-connector-demo/dataclasses/com/axonivy/market/docker/connector/demo/Data.ivyClass b/docker-connector-demo/dataclasses/com/axonivy/market/docker/connector/demo/Data.ivyClass new file mode 100644 index 0000000..5fc0185 --- /dev/null +++ b/docker-connector-demo/dataclasses/com/axonivy/market/docker/connector/demo/Data.ivyClass @@ -0,0 +1,4 @@ +Data #class +com.axonivy.market.docker.connector.demo #namespace +containerId String #field +containerId PERSISTENT #fieldModifier diff --git a/docker-connector-demo/pom.xml b/docker-connector-demo/pom.xml new file mode 100644 index 0000000..129259c --- /dev/null +++ b/docker-connector-demo/pom.xml @@ -0,0 +1,27 @@ + + + 4.0.0 + com.axonivy.market + docker-connector-demo + 1.0.0-SNAPSHOT + iar + + + com.axonivy.market + docker-connector + 10.0.0-SNAPSHOT + iar + + + + + + com.axonivy.ivy.ci + project-build-plugin + 10.0.6 + true + + + + diff --git a/docker-connector-demo/processes/dockerDemo.p.json b/docker-connector-demo/processes/dockerDemo.p.json new file mode 100644 index 0000000..75f5510 --- /dev/null +++ b/docker-connector-demo/processes/dockerDemo.p.json @@ -0,0 +1,140 @@ +{ + "format" : "10.0.0", + "id" : "18A50F6DFF3B27D1", + "config" : { + "data" : "com.axonivy.market.docker.connector.demo.Data" + }, + "elements" : [ { + "id" : "f0", + "type" : "RequestStart", + "name" : "start.ivp", + "config" : { + "callSignature" : "start", + "outLink" : "start.ivp", + "tags" : "demo" + }, + "visual" : { + "at" : { "x" : 88, "y" : 296 } + }, + "connect" : { "id" : "f4", "to" : "f3" } + }, { + "id" : "f1", + "type" : "TaskEnd", + "visual" : { + "at" : { "x" : 968, "y" : 296 } + } + }, { + "id" : "f3", + "type" : "SubProcessCall", + "name" : "Create axonivy-engine container", + "config" : { + "call" : { + "params" : [ + { "name" : "image", "type" : "String" }, + { "name" : "name", "type" : "String" }, + { "name" : "ports", "type" : "List" } + ], + "map" : { + "param.image" : "\"axonivy/axonivy-engine:10.0\"", + "param.name" : "\"axonivy-engine\"" + }, + "code" : [ + "import com.axonivy.connector.docker.PortBinding;", + "PortBinding binding = new PortBinding();", + "binding.publicPort = 8080;", + "binding.internalPort = 8080;", + "", + "param.ports = [binding];" + ] + }, + "processCall" : "docker:createContainer(String,String,List)", + "output" : { + "map" : { + "out" : "in", + "out.containerId" : "result.containerId" + } + } + }, + "visual" : { + "at" : { "x" : 216, "y" : 296 } + }, + "connect" : { "id" : "f6", "to" : "f5" } + }, { + "id" : "f5", + "type" : "SubProcessCall", + "name" : "Start Container", + "config" : { + "processCall" : "docker:startContainer(String)", + "call" : { + "params" : [ + { "name" : "containerId", "type" : "String" } + ], + "map" : { + "param.containerId" : "in.containerId" + } + } + }, + "visual" : { + "at" : { "x" : 360, "y" : 296 } + }, + "connect" : { "id" : "f13", "to" : "f12" } + }, { + "id" : "f7", + "type" : "SubProcessCall", + "name" : "Stop Container", + "config" : { + "processCall" : "docker:stopContainer(String)", + "call" : { + "params" : [ + { "name" : "containerId", "type" : "String" } + ], + "map" : { + "param.containerId" : "in.containerId" + } + } + }, + "visual" : { + "at" : { "x" : 680, "y" : 296 } + }, + "connect" : { "id" : "f10", "to" : "f9" } + }, { + "id" : "f9", + "type" : "SubProcessCall", + "name" : "docker", + "config" : { + "processCall" : "docker:removeContainer(String)", + "call" : { + "params" : [ + { "name" : "containerId", "type" : "String" } + ], + "map" : { + "param.containerId" : "in.containerId" + } + } + }, + "visual" : { + "at" : { "x" : 840, "y" : 296 } + }, + "connect" : { "id" : "f2", "to" : "f1" } + }, { + "id" : "f11", + "type" : "ProcessAnnotation", + "name" : "This demo creates a Docker container for the Docker image axonivy/axonivy-engine:10.0 then starts, stops and removes it.", + "visual" : { + "at" : { "x" : 211, "y" : 165 }, + "size" : { "width" : 274, "height" : 102 } + } + }, { + "id" : "f12", + "type" : "DialogCall", + "name" : "ShowEngine", + "config" : { + "dialogId" : "com.axonivy.market.docker.connector.demo.ShowEngine", + "startMethod" : "start()" + }, + "visual" : { + "at" : { "x" : 520, "y" : 296 } + }, + "connect" : { "id" : "f8", "to" : "f7" } + } ] +} \ No newline at end of file diff --git a/docker-connector-demo/src_hd/com/axonivy/market/docker/connector/demo/ShowEngine/ShowEngine.rddescriptor b/docker-connector-demo/src_hd/com/axonivy/market/docker/connector/demo/ShowEngine/ShowEngine.rddescriptor new file mode 100644 index 0000000..ae605f0 --- /dev/null +++ b/docker-connector-demo/src_hd/com/axonivy/market/docker/connector/demo/ShowEngine/ShowEngine.rddescriptor @@ -0,0 +1,7 @@ + + + + viewTechnology + JSF + + diff --git a/docker-connector-demo/src_hd/com/axonivy/market/docker/connector/demo/ShowEngine/ShowEngine.xhtml b/docker-connector-demo/src_hd/com/axonivy/market/docker/connector/demo/ShowEngine/ShowEngine.xhtml new file mode 100644 index 0000000..d03a529 --- /dev/null +++ b/docker-connector-demo/src_hd/com/axonivy/market/docker/connector/demo/ShowEngine/ShowEngine.xhtml @@ -0,0 +1,28 @@ + + + + Show Engine + + +

+ Axon Ivy Engine running in a container +

+ + + + +
+
+ + +
+
+ +
+
+
+ + \ No newline at end of file diff --git a/docker-connector-demo/src_hd/com/axonivy/market/docker/connector/demo/ShowEngine/ShowEngineData.ivyClass b/docker-connector-demo/src_hd/com/axonivy/market/docker/connector/demo/ShowEngine/ShowEngineData.ivyClass new file mode 100644 index 0000000..1ac74f4 --- /dev/null +++ b/docker-connector-demo/src_hd/com/axonivy/market/docker/connector/demo/ShowEngine/ShowEngineData.ivyClass @@ -0,0 +1,2 @@ +ShowEngineData #class +com.axonivy.market.docker.connector.demo.ShowEngine #namespace diff --git a/docker-connector-demo/src_hd/com/axonivy/market/docker/connector/demo/ShowEngine/ShowEngineProcess.p.json b/docker-connector-demo/src_hd/com/axonivy/market/docker/connector/demo/ShowEngine/ShowEngineProcess.p.json new file mode 100644 index 0000000..b91d45a --- /dev/null +++ b/docker-connector-demo/src_hd/com/axonivy/market/docker/connector/demo/ShowEngine/ShowEngineProcess.p.json @@ -0,0 +1,44 @@ +{ + "format" : "10.0.0", + "id" : "18A510557E128639", + "kind" : "HTML_DIALOG", + "config" : { + "data" : "com.axonivy.market.docker.connector.demo.ShowEngine.ShowEngineData" + }, + "elements" : [ { + "id" : "f0", + "type" : "HtmlDialogStart", + "name" : "start()", + "config" : { + "callSignature" : "start", + "guid" : "18A510557E2EC92A" + }, + "visual" : { + "at" : { "x" : 96, "y" : 64 } + }, + "connect" : { "id" : "f2", "to" : "f1" } + }, { + "id" : "f1", + "type" : "HtmlDialogEnd", + "visual" : { + "at" : { "x" : 224, "y" : 64 } + } + }, { + "id" : "f3", + "type" : "HtmlDialogEventStart", + "name" : "close", + "config" : { + "guid" : "18A510557E378E4D" + }, + "visual" : { + "at" : { "x" : 96, "y" : 160 } + }, + "connect" : { "id" : "f5", "to" : "f4" } + }, { + "id" : "f4", + "type" : "HtmlDialogExit", + "visual" : { + "at" : { "x" : 224, "y" : 160 } + } + } ] +} \ No newline at end of file diff --git a/docker-connector-demo/webContent/layouts/frame-10-full-width.xhtml b/docker-connector-demo/webContent/layouts/frame-10-full-width.xhtml new file mode 100644 index 0000000..06f02b6 --- /dev/null +++ b/docker-connector-demo/webContent/layouts/frame-10-full-width.xhtml @@ -0,0 +1,60 @@ + + + + + + + + + + <ui:insert name="title">Ivy Html Dialog</ui:insert> + + + + + + + + + +
+ + default content + +
+ + + + + + + +
+ \ No newline at end of file diff --git a/docker-connector-demo/webContent/layouts/includes/exception-details.xhtml b/docker-connector-demo/webContent/layouts/includes/exception-details.xhtml new file mode 100644 index 0000000..bbc3cce --- /dev/null +++ b/docker-connector-demo/webContent/layouts/includes/exception-details.xhtml @@ -0,0 +1,109 @@ + + + + + + +

+ +

+ + +

Error id

+

#{errorPage.exceptionId}

+

Error Timestamp

+

#{errorPage.createdAt}

+
+ + + + +

Attributes

+
+ + + + + + + + + + + + + + + +
NameValue
+
+
+

Thrown by

+

Process: + +
Element: + +

+
+ + +

Process call stack

+ +
#{caller.callerElement}
+
+
+ +

Technical cause

+
#{causedBy.class.simpleName}: #{causedBy.message.trim()}
+
+
+ +

Request Uri

+

#{errorPage.getRequestUri()}

+
+

Servlet

+

#{errorPage.getServletName()}

+
+ +

Application

+

#{errorPage.applicationName}

+
+ + +

Thread local values

+
+ + + + + + + + + + + + + + + +
KeyValue
+
+
+
+ +

Stack-Trace

+
#{errorPage.getStackTrace()}
+
+ diff --git a/docker-connector-demo/webContent/layouts/includes/exception.xhtml b/docker-connector-demo/webContent/layouts/includes/exception.xhtml new file mode 100644 index 0000000..1b255a2 --- /dev/null +++ b/docker-connector-demo/webContent/layouts/includes/exception.xhtml @@ -0,0 +1,47 @@ + + + + + + + + + +
+
+ + +
+ + + + + + + + + +
+ + \ No newline at end of file diff --git a/docker-connector-demo/webContent/layouts/includes/footer.xhtml b/docker-connector-demo/webContent/layouts/includes/footer.xhtml new file mode 100644 index 0000000..f21699e --- /dev/null +++ b/docker-connector-demo/webContent/layouts/includes/footer.xhtml @@ -0,0 +1,18 @@ + + + +
+ + #{ivyAdvisor.applicationName} + + +
+
+ + \ No newline at end of file diff --git a/docker-connector-demo/webContent/layouts/includes/progress-loader.xhtml b/docker-connector-demo/webContent/layouts/includes/progress-loader.xhtml new file mode 100644 index 0000000..0d68a75 --- /dev/null +++ b/docker-connector-demo/webContent/layouts/includes/progress-loader.xhtml @@ -0,0 +1,15 @@ + + + + +
+
+
Loading...
+
+
+ + + +
+
\ No newline at end of file diff --git a/docker-connector-product/product.json b/docker-connector-product/product.json index a5a4b33..785b84e 100644 --- a/docker-connector-product/product.json +++ b/docker-connector-product/product.json @@ -6,8 +6,8 @@ "data": { "projects": [ { - "groupId": "MY-GROUP-ID", - "artifactId": "MY-PRODUCT-NAME-demo", + "groupId": "com.axonivy.market", + "artifactId": "docker-connector-demo", "version": "${version}", "type": "iar" } @@ -28,8 +28,8 @@ "data": { "dependencies": [ { - "groupId": "MY-GROUP-ID", - "artifactId": "MY-PRODUCT-NAME", + "groupId": "com.axonivy.market", + "artifactId": "docker-connector", "version": "${version}", "type": "iar" } diff --git a/docker-connector/dataclasses/com/axonivy/connector/docker/Data.ivyClass b/docker-connector/dataclasses/com/axonivy/connector/docker/Data.ivyClass new file mode 100644 index 0000000..814e1ef --- /dev/null +++ b/docker-connector/dataclasses/com/axonivy/connector/docker/Data.ivyClass @@ -0,0 +1,10 @@ +Data #class +com.axonivy.connector.docker #namespace +image String #field +image PERSISTENT #fieldModifier +ports List #field +ports PERSISTENT #fieldModifier +containerId String #field +containerId PERSISTENT #fieldModifier +name String #field +name PERSISTENT #fieldModifier diff --git a/docker-connector/dataclasses/com/axonivy/connector/docker/PortBinding.ivyClass b/docker-connector/dataclasses/com/axonivy/connector/docker/PortBinding.ivyClass new file mode 100644 index 0000000..e3e591c --- /dev/null +++ b/docker-connector/dataclasses/com/axonivy/connector/docker/PortBinding.ivyClass @@ -0,0 +1,6 @@ +PortBinding #class +com.axonivy.connector.docker #namespace +publicPort Number #field +publicPort PERSISTENT #fieldModifier +internalPort Number #field +internalPort PERSISTENT #fieldModifier diff --git a/docker-connector/processes/docker.p.json b/docker-connector/processes/docker.p.json new file mode 100644 index 0000000..bb9e12a --- /dev/null +++ b/docker-connector/processes/docker.p.json @@ -0,0 +1,209 @@ +{ + "format" : "10.0.0", + "id" : "18A50DF32C4DF1E5", + "kind" : "CALLABLE_SUB", + "config" : { + "data" : "com.axonivy.connector.docker.Data" + }, + "elements" : [ { + "id" : "f0", + "type" : "CallSubStart", + "name" : "createContainer(String,String,List)", + "config" : { + "callSignature" : "createContainer", + "input" : { + "params" : [ + { "name" : "image", "type" : "String" }, + { "name" : "name", "type" : "String" }, + { "name" : "ports", "type" : "List" } + ], + "map" : { + "out.image" : "param.image", + "out.name" : "param.name", + "out.ports" : "param.ports" + } + }, + "result" : { + "params" : [ + { "name" : "containerId", "type" : "String" } + ], + "map" : { + "result.containerId" : "in.containerId" + } + } + }, + "visual" : { + "at" : { "x" : 176, "y" : 72 } + }, + "connect" : { "id" : "f4", "to" : "f3" } + }, { + "id" : "f1", + "type" : "CallSubEnd", + "visual" : { + "at" : { "x" : 504, "y" : 72 } + } + }, { + "id" : "f3", + "type" : "Script", + "name" : "Create Container", + "config" : { + "output" : { + "code" : [ + "import com.github.dockerjava.api.model.Ports.Binding;", + "import com.github.dockerjava.api.model.ExposedPort;", + "import com.github.dockerjava.api.command.CreateContainerResponse;", + "import com.github.dockerjava.api.model.HostConfig;", + "import com.github.dockerjava.api.model.PortBinding;", + "import com.axonivy.connector.docker.IvyDockerClient;", + "", + "Binding.bindPort(15);", + "List ports = [];", + "for (com.axonivy.connector.docker.PortBinding binding : in.ports) { ", + " Binding b = Binding.bindPort(binding.internalPort);", + " ports.add(new PortBinding(b, new ExposedPort(binding.publicPort)));", + "}", + "HostConfig hostConfig = HostConfig.newHostConfig();", + "if (! ports.isEmpty()) {", + " hostConfig.withPortBindings(ports);", + "}", + "CreateContainerResponse response = IvyDockerClient.instance()", + " .createContainerCmd(in.image)", + " .withName(in.name)", + " .withHostConfig(hostConfig)", + " .exec();", + "out.containerId = response.id;" + ] + } + }, + "visual" : { + "at" : { "x" : 360, "y" : 72 } + }, + "connect" : { "id" : "f2", "to" : "f1" } + }, { + "id" : "f5", + "type" : "CallSubStart", + "name" : "startContainer(String)", + "config" : { + "callSignature" : "startContainer", + "input" : { + "params" : [ + { "name" : "containerId", "type" : "String" } + ], + "map" : { + "out.containerId" : "param.containerId" + } + } + }, + "visual" : { + "at" : { "x" : 176, "y" : 184 } + }, + "connect" : { "id" : "f8", "to" : "f7" } + }, { + "id" : "f6", + "type" : "CallSubEnd", + "visual" : { + "at" : { "x" : 512, "y" : 184 } + } + }, { + "id" : "f7", + "type" : "Script", + "name" : "Start Container", + "config" : { + "output" : { + "code" : [ + "import com.axonivy.connector.docker.IvyDockerClient;", + "", + "IvyDockerClient.instance().startContainer(in.containerId);" + ] + } + }, + "visual" : { + "at" : { "x" : 368, "y" : 184 } + }, + "connect" : { "id" : "f9", "to" : "f6" } + }, { + "id" : "f10", + "type" : "CallSubStart", + "name" : "stopContainer(String)", + "config" : { + "callSignature" : "stopContainer", + "input" : { + "params" : [ + { "name" : "containerId", "type" : "String" } + ], + "map" : { + "out.containerId" : "param.containerId" + } + } + }, + "visual" : { + "at" : { "x" : 176, "y" : 288 } + }, + "connect" : { "id" : "f14", "to" : "f12" } + }, { + "id" : "f11", + "type" : "CallSubEnd", + "visual" : { + "at" : { "x" : 512, "y" : 288 } + } + }, { + "id" : "f12", + "type" : "Script", + "name" : "Stop Container", + "config" : { + "output" : { + "code" : [ + "import com.axonivy.connector.docker.IvyDockerClient;", + "", + "IvyDockerClient.instance().stopContainer(in.containerId);" + ] + } + }, + "visual" : { + "at" : { "x" : 368, "y" : 288 } + }, + "connect" : { "id" : "f13", "to" : "f11" } + }, { + "id" : "f15", + "type" : "CallSubStart", + "name" : "removeContainer", + "config" : { + "callSignature" : "removeContainer", + "input" : { + "params" : [ + { "name" : "containerId", "type" : "String" } + ], + "map" : { + "out.containerId" : "param.containerId" + } + } + }, + "visual" : { + "at" : { "x" : 184, "y" : 408 } + }, + "connect" : { "id" : "f18", "to" : "f17" } + }, { + "id" : "f16", + "type" : "CallSubEnd", + "visual" : { + "at" : { "x" : 520, "y" : 408 } + } + }, { + "id" : "f17", + "type" : "Script", + "name" : "Remove Container", + "config" : { + "output" : { + "code" : [ + "import com.axonivy.connector.docker.IvyDockerClient;", + "", + "IvyDockerClient.instance().removeContainer(in.containerId);" + ] + } + }, + "visual" : { + "at" : { "x" : 376, "y" : 408 } + }, + "connect" : { "id" : "f19", "to" : "f16" } + } ] +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 03b4111..2f568e9 100644 --- a/pom.xml +++ b/pom.xml @@ -8,8 +8,8 @@ ${project.name} - + ${project.name}-demo + ${project.name}-product From 6055b5d3d83b98ebd321dc6a55e01cb312e6a3bd Mon Sep 17 00:00:00 2001 From: Reto Weiss Date: Mon, 11 Sep 2023 15:17:05 +0200 Subject: [PATCH 3/8] Add test project with a web test Exclude Guava from the docker-4-java dependencies are we already deliver Guava in a newer version. --- .gitignore | 1 + docker-connector-demo/config/variables.yaml | 1 - docker-connector-demo/pom.xml | 5 +- .../processes/dockerDemo.p.json | 2 +- .../demo/ShowEngine/ShowEngine.xhtml | 2 +- docker-connector-test/.classpath | 40 +++++++++++++++ docker-connector-test/.gitignore | 19 +++++++ docker-connector-test/.project | 49 +++++++++++++++++++ docker-connector-test/.settings/.jsdtscope | 12 +++++ .../.settings/ch.ivyteam.ivy.designer.prefs | 5 ++ .../.settings/org.eclipse.jdt.core.prefs | 10 ++++ .../org.eclipse.wst.common.component | 11 +++++ ...se.wst.common.project.facet.core.prefs.xml | 7 +++ ....eclipse.wst.common.project.facet.core.xml | 8 +++ .../.settings/org.eclipse.wst.css.core.prefs | 2 + ...rg.eclipse.wst.jsdt.ui.superType.container | 1 + .../org.eclipse.wst.jsdt.ui.superType.name | 1 + .../config/custom-fields.yaml | 20 ++++++++ docker-connector-test/config/databases.yaml | 1 + docker-connector-test/config/overrides.any | 1 + docker-connector-test/config/persistence.xml | 2 + .../config/rest-clients.yaml | 1 + docker-connector-test/config/roles.xml | 4 ++ docker-connector-test/config/users.xml | 2 + docker-connector-test/config/variables.yaml | 8 +++ .../config/webservice-clients.yaml | 1 + .../docker/connector/test/Data.ivyClass | 2 + docker-connector-test/pom.xml | 37 ++++++++++++++ .../connector/test/ITDockerConnector.java | 42 ++++++++++++++++ docker-connector/config/variables.yaml | 7 ++- docker-connector/pom.xml | 33 ++++++++----- docker-connector/processes/docker.p.json | 4 +- pom.xml | 2 +- 33 files changed, 320 insertions(+), 23 deletions(-) create mode 100644 docker-connector-test/.classpath create mode 100644 docker-connector-test/.gitignore create mode 100644 docker-connector-test/.project create mode 100644 docker-connector-test/.settings/.jsdtscope create mode 100644 docker-connector-test/.settings/ch.ivyteam.ivy.designer.prefs create mode 100644 docker-connector-test/.settings/org.eclipse.jdt.core.prefs create mode 100644 docker-connector-test/.settings/org.eclipse.wst.common.component create mode 100644 docker-connector-test/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml create mode 100644 docker-connector-test/.settings/org.eclipse.wst.common.project.facet.core.xml create mode 100644 docker-connector-test/.settings/org.eclipse.wst.css.core.prefs create mode 100644 docker-connector-test/.settings/org.eclipse.wst.jsdt.ui.superType.container create mode 100644 docker-connector-test/.settings/org.eclipse.wst.jsdt.ui.superType.name create mode 100644 docker-connector-test/config/custom-fields.yaml create mode 100644 docker-connector-test/config/databases.yaml create mode 100644 docker-connector-test/config/overrides.any create mode 100644 docker-connector-test/config/persistence.xml create mode 100644 docker-connector-test/config/rest-clients.yaml create mode 100644 docker-connector-test/config/roles.xml create mode 100644 docker-connector-test/config/users.xml create mode 100644 docker-connector-test/config/variables.yaml create mode 100644 docker-connector-test/config/webservice-clients.yaml create mode 100644 docker-connector-test/dataclasses/com/axonivy/market/docker/connector/test/Data.ivyClass create mode 100644 docker-connector-test/pom.xml create mode 100644 docker-connector-test/src_test/com/axonivy/market/docker/connector/test/ITDockerConnector.java diff --git a/.gitignore b/.gitignore index c6cc0de..b8abc3a 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ lib/mvn-deps/ logs/ src_dataClasses/ src_wsproc/ +/.metadata/ diff --git a/docker-connector-demo/config/variables.yaml b/docker-connector-demo/config/variables.yaml index 64c8fa0..d9ce3d6 100644 --- a/docker-connector-demo/config/variables.yaml +++ b/docker-connector-demo/config/variables.yaml @@ -6,4 +6,3 @@ # '/Config/_/variables.yaml # Variables: -# myVariable: value diff --git a/docker-connector-demo/pom.xml b/docker-connector-demo/pom.xml index 129259c..94981f4 100644 --- a/docker-connector-demo/pom.xml +++ b/docker-connector-demo/pom.xml @@ -4,8 +4,11 @@ 4.0.0 com.axonivy.market docker-connector-demo - 1.0.0-SNAPSHOT + 10.0.0-SNAPSHOT iar + + Axon Ivy AG + com.axonivy.market diff --git a/docker-connector-demo/processes/dockerDemo.p.json b/docker-connector-demo/processes/dockerDemo.p.json index 75f5510..2c5318e 100644 --- a/docker-connector-demo/processes/dockerDemo.p.json +++ b/docker-connector-demo/processes/dockerDemo.p.json @@ -41,7 +41,7 @@ "code" : [ "import com.axonivy.connector.docker.PortBinding;", "PortBinding binding = new PortBinding();", - "binding.publicPort = 8080;", + "binding.publicPort = 9090;", "binding.internalPort = 8080;", "", "param.ports = [binding];" diff --git a/docker-connector-demo/src_hd/com/axonivy/market/docker/connector/demo/ShowEngine/ShowEngine.xhtml b/docker-connector-demo/src_hd/com/axonivy/market/docker/connector/demo/ShowEngine/ShowEngine.xhtml index d03a529..bdfcfab 100644 --- a/docker-connector-demo/src_hd/com/axonivy/market/docker/connector/demo/ShowEngine/ShowEngine.xhtml +++ b/docker-connector-demo/src_hd/com/axonivy/market/docker/connector/demo/ShowEngine/ShowEngine.xhtml @@ -13,7 +13,7 @@ - +
diff --git a/docker-connector-test/.classpath b/docker-connector-test/.classpath new file mode 100644 index 0000000..8a52195 --- /dev/null +++ b/docker-connector-test/.classpath @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docker-connector-test/.gitignore b/docker-connector-test/.gitignore new file mode 100644 index 0000000..1b2547b --- /dev/null +++ b/docker-connector-test/.gitignore @@ -0,0 +1,19 @@ +# general +Thumbs.db +.DS_Store +*~ +*.log + +# java +*.class +hs_err_pid* + +# maven +target/ +lib/mvn-deps/ + +# ivy +classes/ +src_dataClasses/ +src_wsproc/ +logs/ diff --git a/docker-connector-test/.project b/docker-connector-test/.project new file mode 100644 index 0000000..f560f36 --- /dev/null +++ b/docker-connector-test/.project @@ -0,0 +1,49 @@ + + + docker-connector-test + + + + + + ch.ivyteam.ivy.designer.dataClasses.ui.ivyDataClassBuilder + + + + + ch.ivyteam.ivy.designer.process.ui.ivyWebServiceProcessClassBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + ch.ivyteam.ivy.designer.ide.ivyModelValidationBuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + ch.ivyteam.ivy.project.IvyProjectNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.jem.beaninfo.BeanInfoNature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.wst.jsdt.core.jsNature + + diff --git a/docker-connector-test/.settings/.jsdtscope b/docker-connector-test/.settings/.jsdtscope new file mode 100644 index 0000000..cf5ec79 --- /dev/null +++ b/docker-connector-test/.settings/.jsdtscope @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/docker-connector-test/.settings/ch.ivyteam.ivy.designer.prefs b/docker-connector-test/.settings/ch.ivyteam.ivy.designer.prefs new file mode 100644 index 0000000..552c153 --- /dev/null +++ b/docker-connector-test/.settings/ch.ivyteam.ivy.designer.prefs @@ -0,0 +1,5 @@ +ch.ivyteam.ivy.designer.preferences.DataClassPreferencePage\:DEFAULT_DATA_CLASS=com.axonivy.market.docker.connector.test.Data +ch.ivyteam.ivy.designer.preferences.DataClassPreferencePage\:DEFAULT_NAMESPACE=com.axonivy.market.docker.connector.test +ch.ivyteam.ivy.project.preferences\:PRIMEFACES_VERSION=11 +ch.ivyteam.ivy.project.preferences\:PROJECT_VERSION=100000 +eclipse.preferences.version=1 diff --git a/docker-connector-test/.settings/org.eclipse.jdt.core.prefs b/docker-connector-test/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..f78f7f7 --- /dev/null +++ b/docker-connector-test/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,10 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/docker-connector-test/.settings/org.eclipse.wst.common.component b/docker-connector-test/.settings/org.eclipse.wst.common.component new file mode 100644 index 0000000..31ae991 --- /dev/null +++ b/docker-connector-test/.settings/org.eclipse.wst.common.component @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/docker-connector-test/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml b/docker-connector-test/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml new file mode 100644 index 0000000..0d46547 --- /dev/null +++ b/docker-connector-test/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/docker-connector-test/.settings/org.eclipse.wst.common.project.facet.core.xml b/docker-connector-test/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 0000000..c2098f9 --- /dev/null +++ b/docker-connector-test/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/docker-connector-test/.settings/org.eclipse.wst.css.core.prefs b/docker-connector-test/.settings/org.eclipse.wst.css.core.prefs new file mode 100644 index 0000000..96b96cd --- /dev/null +++ b/docker-connector-test/.settings/org.eclipse.wst.css.core.prefs @@ -0,0 +1,2 @@ +css-profile/=org.eclipse.wst.css.core.cssprofile.css3 +eclipse.preferences.version=1 diff --git a/docker-connector-test/.settings/org.eclipse.wst.jsdt.ui.superType.container b/docker-connector-test/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 0000000..3bd5d0a --- /dev/null +++ b/docker-connector-test/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/docker-connector-test/.settings/org.eclipse.wst.jsdt.ui.superType.name b/docker-connector-test/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 0000000..05bd71b --- /dev/null +++ b/docker-connector-test/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/docker-connector-test/config/custom-fields.yaml b/docker-connector-test/config/custom-fields.yaml new file mode 100644 index 0000000..aa19ae0 --- /dev/null +++ b/docker-connector-test/config/custom-fields.yaml @@ -0,0 +1,20 @@ +# == Custom Fields Information == +# +# You can define here your project custom fields. +# Have a look at our documentation for more information. +# +CustomFields: +# Tasks: +# MyTaskCustomField: +# Label: My task custom field +# Description: This new task custom field can be used to ... +# Type: STRING +# Cases: +# MyCaseCustomField: +# Label: My case custom field +# Description: This new case custom field can be used to ... +# Type: STRING +# Starts: +# MyStartCustomField: +# Label: My start custom field +# Description: This new start custom field can be used to ... diff --git a/docker-connector-test/config/databases.yaml b/docker-connector-test/config/databases.yaml new file mode 100644 index 0000000..247b128 --- /dev/null +++ b/docker-connector-test/config/databases.yaml @@ -0,0 +1 @@ +Databases: diff --git a/docker-connector-test/config/overrides.any b/docker-connector-test/config/overrides.any new file mode 100644 index 0000000..f59ec20 --- /dev/null +++ b/docker-connector-test/config/overrides.any @@ -0,0 +1 @@ +* \ No newline at end of file diff --git a/docker-connector-test/config/persistence.xml b/docker-connector-test/config/persistence.xml new file mode 100644 index 0000000..d6b96d7 --- /dev/null +++ b/docker-connector-test/config/persistence.xml @@ -0,0 +1,2 @@ + + diff --git a/docker-connector-test/config/rest-clients.yaml b/docker-connector-test/config/rest-clients.yaml new file mode 100644 index 0000000..8e85296 --- /dev/null +++ b/docker-connector-test/config/rest-clients.yaml @@ -0,0 +1 @@ +RestClients: diff --git a/docker-connector-test/config/roles.xml b/docker-connector-test/config/roles.xml new file mode 100644 index 0000000..59892fe --- /dev/null +++ b/docker-connector-test/config/roles.xml @@ -0,0 +1,4 @@ + + + Everybody + diff --git a/docker-connector-test/config/users.xml b/docker-connector-test/config/users.xml new file mode 100644 index 0000000..51a6906 --- /dev/null +++ b/docker-connector-test/config/users.xml @@ -0,0 +1,2 @@ + + diff --git a/docker-connector-test/config/variables.yaml b/docker-connector-test/config/variables.yaml new file mode 100644 index 0000000..d9ce3d6 --- /dev/null +++ b/docker-connector-test/config/variables.yaml @@ -0,0 +1,8 @@ +# == Variables == +# +# You can define here your project Variables. +# If you want to define/override a Variable for a specific Environment, +# add an additional ‘variables.yaml’ file in a subdirectory in the ‘Config’ folder: +# '/Config/_/variables.yaml +# +Variables: diff --git a/docker-connector-test/config/webservice-clients.yaml b/docker-connector-test/config/webservice-clients.yaml new file mode 100644 index 0000000..060b018 --- /dev/null +++ b/docker-connector-test/config/webservice-clients.yaml @@ -0,0 +1 @@ +WebServiceClients: diff --git a/docker-connector-test/dataclasses/com/axonivy/market/docker/connector/test/Data.ivyClass b/docker-connector-test/dataclasses/com/axonivy/market/docker/connector/test/Data.ivyClass new file mode 100644 index 0000000..c671fce --- /dev/null +++ b/docker-connector-test/dataclasses/com/axonivy/market/docker/connector/test/Data.ivyClass @@ -0,0 +1,2 @@ +Data #class +com.axonivy.market.docker.connector.test #namespace diff --git a/docker-connector-test/pom.xml b/docker-connector-test/pom.xml new file mode 100644 index 0000000..ff67f7d --- /dev/null +++ b/docker-connector-test/pom.xml @@ -0,0 +1,37 @@ + + + 4.0.0 + com.axonivy.market + docker-connector-test + 10.0.0-SNAPSHOT + iar-integration-test + + Axon Ivy AG + + + + com.axonivy.market + docker-connector-demo + ${project.version} + iar + + + com.axonivy.ivy.webtest + web-tester + 10.0.0 + test + + + + src_test + + + com.axonivy.ivy.ci + project-build-plugin + 10.0.6 + true + + + + diff --git a/docker-connector-test/src_test/com/axonivy/market/docker/connector/test/ITDockerConnector.java b/docker-connector-test/src_test/com/axonivy/market/docker/connector/test/ITDockerConnector.java new file mode 100644 index 0000000..7ece8e2 --- /dev/null +++ b/docker-connector-test/src_test/com/axonivy/market/docker/connector/test/ITDockerConnector.java @@ -0,0 +1,42 @@ +package com.axonivy.market.docker.connector.test; + +import static com.codeborne.selenide.Selenide.$; +import static com.codeborne.selenide.Selenide.open; +import static org.assertj.core.api.Assertions.assertThat; +import java.time.Duration; +import org.junit.jupiter.api.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriverException; +import com.axonivy.ivy.webtest.IvyWebTest; +import com.axonivy.ivy.webtest.engine.EngineUrl; +import com.codeborne.selenide.Selenide; + +@IvyWebTest +public class ITDockerConnector { + + @Test + public void demo() { + open(EngineUrl.createProcessUrl("docker-connector-demo/18A50F6DFF3B27D1/start.ivp")); + + // Open link to started engine + $(By.id("form:OpenEngine")).click(); + + + Selenide.Wait() + .withTimeout(Duration.ofMinutes(1)) + .pollingEvery(Duration.ofSeconds(5)) + .ignoring(WebDriverException.class) + .ignoring(AssertionError.class) + .until(driver -> { + Selenide.switchTo().window(1); + Selenide.refresh(); + assertThat(Selenide.title()).contains("Axon Ivy Engine"); + return true; + }); + + Selenide.switchTo().window(0); + + $(By.id("form:proceed")).click(); + } + +} \ No newline at end of file diff --git a/docker-connector/config/variables.yaml b/docker-connector/config/variables.yaml index c4ba134..2b58dfe 100644 --- a/docker-connector/config/variables.yaml +++ b/docker-connector/config/variables.yaml @@ -6,15 +6,14 @@ # '/Config/_/variables.yaml # Variables: -# myVariable: value Docker: # URL to communicate with the docker daemon - # Windows Pipe: + # Windows Pipe (localhost only): # npipe:////./pipe/dockerDesktopLinuxEngine - # Linux: + # Linux (localhost only): # unix:///var/run/docker.sock # TCP (Outside container): # tcp://localhost:2375 # TCP (Inside a container): # tcp://host.docker.internal:2375 - URL: "tcp://localhost:2375/" \ No newline at end of file + URL: "unix:///var/run/docker.sock" \ No newline at end of file diff --git a/docker-connector/pom.xml b/docker-connector/pom.xml index 7815255..b864760 100644 --- a/docker-connector/pom.xml +++ b/docker-connector/pom.xml @@ -6,6 +6,27 @@ docker-connector 10.0.0-SNAPSHOT iar + + Axon Ivy AG + + + + com.github.docker-java + docker-java-core + 3.3.3 + + + com.google.guava + guava + + + + + com.github.docker-java + docker-java-transport-httpclient5 + 3.3.3 + + @@ -16,16 +37,4 @@ - - - com.github.docker-java - docker-java-core - 3.3.3 - - - com.github.docker-java - docker-java-transport-httpclient5 - 3.3.3 - - diff --git a/docker-connector/processes/docker.p.json b/docker-connector/processes/docker.p.json index bb9e12a..4f491a3 100644 --- a/docker-connector/processes/docker.p.json +++ b/docker-connector/processes/docker.p.json @@ -59,8 +59,8 @@ "Binding.bindPort(15);", "List ports = [];", "for (com.axonivy.connector.docker.PortBinding binding : in.ports) { ", - " Binding b = Binding.bindPort(binding.internalPort);", - " ports.add(new PortBinding(b, new ExposedPort(binding.publicPort)));", + " Binding b = Binding.bindPort(binding.publicPort);", + " ports.add(new PortBinding(b, new ExposedPort(binding.internalPort)));", "}", "HostConfig hostConfig = HostConfig.newHostConfig();", "if (! ports.isEmpty()) {", diff --git a/pom.xml b/pom.xml index 2f568e9..468789a 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ ${project.name} ${project.name}-demo - + ${project.name}-test ${project.name}-product From 2d6f42375d3c009cb6be6dfeb4b4ed62f6629734 Mon Sep 17 00:00:00 2001 From: Reto Weiss Date: Mon, 11 Sep 2023 16:52:48 +0200 Subject: [PATCH 4/8] Provide description, demo, setup and correct mvn deps --- docker-connector-product/README.md | 9 +++++---- docker-connector-product/product.json | 21 --------------------- 2 files changed, 5 insertions(+), 25 deletions(-) diff --git a/docker-connector-product/README.md b/docker-connector-product/README.md index ddf38c0..a61cae9 100644 --- a/docker-connector-product/README.md +++ b/docker-connector-product/README.md @@ -1,15 +1,16 @@ # Docker Connector -YOUR DESCRIPTION GOES HERE +Create, start, stop, remove Docker containers with the Axon Ivy's Docker Connector directly from your business processes. ## Demo -YOUR DEMO DESCRIPTION GOES HERE +The demo process creates and starts an additional Axon Ivy Engine in a Docker container. +Then the process shows a HTML Dialog where you can open an additional browser tab that shows the info page of the Axon Ivy Engine. +If you proceed the HTML Dialog then the container gets stopped and removed. ## Setup -YOUR SETUP DESCRIPTION GOES HERE - +To setup the Docker Connnector, add the following variable to your Axon Ivy Project: ``` @variables.yaml@ ``` diff --git a/docker-connector-product/product.json b/docker-connector-product/product.json index 785b84e..662691b 100644 --- a/docker-connector-product/product.json +++ b/docker-connector-product/product.json @@ -44,27 +44,6 @@ } ] } - }, - { - "id": "maven-dropins", - "data": { - "dependencies": [ - { - "groupId": "MY-GROUP-ID", - "artifactId": "MY-PRODUCT-NAME", - "version": "${version}" - } - ], - "repositories": [ - { - "id": "maven.axonivy.com", - "url": "https://maven.axonivy.com", - "snapshots": { - "enabled": "true" - } - } - ] - } } ] } From ab6a673988245770f70ef604c84ae6bb53b32a56 Mon Sep 17 00:00:00 2001 From: Reto Weiss Date: Mon, 11 Sep 2023 17:07:36 +0200 Subject: [PATCH 5/8] Add connector tag an docker icon --- docker-connector/processes/docker.p.json | 24 ++++++++++++------- docker-connector/webContent/icons/docker.png | Bin 0 -> 522 bytes 2 files changed, 16 insertions(+), 8 deletions(-) create mode 100644 docker-connector/webContent/icons/docker.png diff --git a/docker-connector/processes/docker.p.json b/docker-connector/processes/docker.p.json index bb9e12a..e2c5965 100644 --- a/docker-connector/processes/docker.p.json +++ b/docker-connector/processes/docker.p.json @@ -30,10 +30,12 @@ "map" : { "result.containerId" : "in.containerId" } - } + }, + "tags" : "connector" }, "visual" : { - "at" : { "x" : 176, "y" : 72 } + "at" : { "x" : 176, "y" : 72 }, + "icon" : "res:/webContent/icons/docker.png?small" }, "connect" : { "id" : "f4", "to" : "f3" } }, { @@ -92,10 +94,12 @@ "map" : { "out.containerId" : "param.containerId" } - } + }, + "tags" : "connector" }, "visual" : { - "at" : { "x" : 176, "y" : 184 } + "at" : { "x" : 176, "y" : 184 }, + "icon" : "res:/webContent/icons/docker.png?small" }, "connect" : { "id" : "f8", "to" : "f7" } }, { @@ -134,10 +138,12 @@ "map" : { "out.containerId" : "param.containerId" } - } + }, + "tags" : "connector" }, "visual" : { - "at" : { "x" : 176, "y" : 288 } + "at" : { "x" : 176, "y" : 288 }, + "icon" : "res:/webContent/icons/docker.png?small" }, "connect" : { "id" : "f14", "to" : "f12" } }, { @@ -176,10 +182,12 @@ "map" : { "out.containerId" : "param.containerId" } - } + }, + "tags" : "connector" }, "visual" : { - "at" : { "x" : 184, "y" : 408 } + "at" : { "x" : 184, "y" : 408 }, + "icon" : "res:/webContent/icons/docker.png?small" }, "connect" : { "id" : "f18", "to" : "f17" } }, { diff --git a/docker-connector/webContent/icons/docker.png b/docker-connector/webContent/icons/docker.png new file mode 100644 index 0000000000000000000000000000000000000000..a6c93645ae592f8074f26d53e90d4b0fba21806e GIT binary patch literal 522 zcmV+l0`>igP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0iQ`kK~y+T%~3r_ zLQxdH_db7Kgb7kZ6to24PlmmwpslH?FOF>q~_ER z(GNjjl%)3b_8omb5Fy;^gYSLkJMZ3e&pns@Ik>4E2u8E2QLb)E#)=A)8@c3E&HUAd zwgTQr+QvEK(qJ{4D%?i3o=fKP>_wnS!e zEvsaojiACrL61+ADJSR?Sk^s?un!?rQPBx?LLJZw8Z!J5eRw>qyKY{-M~r$sRjt=n zXdj``fiIldl}!5JK5@2$Han9{MO21*IOk``B&C!W&^Pc9%q!kVW*RFs7#mmut6;?> z#ndX@zlgdY&{?n_)G)6S_lDE01$1v~CMH_BmeTcb5I=z1?{o4aDo{ky4R(urr(MkG zvCsn<8sZ5BU82UhSZ{462qE|u^u1|+#TVLMy-kGnOy7XW$0yHGHH!GLnd(3pmp{cT z%oh^cwwbeF4b2zHjN%37FfKoAFGy3r6P#TQ_BgJOcLMY({|=1(0G0!Pv7j Date: Tue, 12 Sep 2023 08:21:54 +0200 Subject: [PATCH 6/8] Changes suggested by review --- docker-connector-demo/config/variables.yaml | 2 ++ docker-connector-demo/processes/dockerDemo.p.json | 14 +++++++++----- docker-connector-product/README.md | 2 +- docker-connector/pom.xml | 2 +- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/docker-connector-demo/config/variables.yaml b/docker-connector-demo/config/variables.yaml index d9ce3d6..32ff8dd 100644 --- a/docker-connector-demo/config/variables.yaml +++ b/docker-connector-demo/config/variables.yaml @@ -6,3 +6,5 @@ # '/Config/_/variables.yaml # Variables: + AxonIvyEngine: + Port: 9090 \ No newline at end of file diff --git a/docker-connector-demo/processes/dockerDemo.p.json b/docker-connector-demo/processes/dockerDemo.p.json index 2c5318e..b4e8383 100644 --- a/docker-connector-demo/processes/dockerDemo.p.json +++ b/docker-connector-demo/processes/dockerDemo.p.json @@ -41,7 +41,7 @@ "code" : [ "import com.axonivy.connector.docker.PortBinding;", "PortBinding binding = new PortBinding();", - "binding.publicPort = 9090;", + "binding.publicPort = ivy.var.AxonIvyEngine_Port.toNumber();", "binding.internalPort = 8080;", "", "param.ports = [binding];" @@ -56,7 +56,8 @@ } }, "visual" : { - "at" : { "x" : 216, "y" : 296 } + "at" : { "x" : 216, "y" : 296 }, + "icon" : "res:/webContent/icons/docker.png" }, "connect" : { "id" : "f6", "to" : "f5" } }, { @@ -75,7 +76,8 @@ } }, "visual" : { - "at" : { "x" : 360, "y" : 296 } + "at" : { "x" : 360, "y" : 296 }, + "icon" : "res:/webContent/icons/docker.png" }, "connect" : { "id" : "f13", "to" : "f12" } }, { @@ -94,7 +96,8 @@ } }, "visual" : { - "at" : { "x" : 680, "y" : 296 } + "at" : { "x" : 680, "y" : 296 }, + "icon" : "res:/webContent/icons/docker.png" }, "connect" : { "id" : "f10", "to" : "f9" } }, { @@ -113,7 +116,8 @@ } }, "visual" : { - "at" : { "x" : 840, "y" : 296 } + "at" : { "x" : 840, "y" : 296 }, + "icon" : "res:/webContent/icons/docker.png" }, "connect" : { "id" : "f2", "to" : "f1" } }, { diff --git a/docker-connector-product/README.md b/docker-connector-product/README.md index a61cae9..30aed7d 100644 --- a/docker-connector-product/README.md +++ b/docker-connector-product/README.md @@ -6,7 +6,7 @@ Create, start, stop, remove Docker containers with the Axon Ivy's Docker Connect The demo process creates and starts an additional Axon Ivy Engine in a Docker container. Then the process shows a HTML Dialog where you can open an additional browser tab that shows the info page of the Axon Ivy Engine. -If you proceed the HTML Dialog then the container gets stopped and removed. +If you proceed in the HTML Dialog, the container gets stopped and removed. ## Setup diff --git a/docker-connector/pom.xml b/docker-connector/pom.xml index b864760..4624a24 100644 --- a/docker-connector/pom.xml +++ b/docker-connector/pom.xml @@ -17,7 +17,7 @@ com.google.guava - guava + guava From 7753dd5d2cba7d616cd4afe66ee1f5de6eb2f0bc Mon Sep 17 00:00:00 2001 From: Reto Weiss Date: Mon, 23 Oct 2023 13:26:55 +0200 Subject: [PATCH 7/8] Remove commented code and improve documentation for podman --- docker-connector/config/variables.yaml | 10 ++++++++-- .../com/axonivy/connector/docker/IvyDockerClient.java | 4 ---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/docker-connector/config/variables.yaml b/docker-connector/config/variables.yaml index 2b58dfe..e660760 100644 --- a/docker-connector/config/variables.yaml +++ b/docker-connector/config/variables.yaml @@ -8,12 +8,18 @@ Variables: Docker: # URL to communicate with the docker daemon - # Windows Pipe (localhost only): + # Windows Docker Desktop [https://www.docker.com/products/docker-desktop/] (localhost only): # npipe:////./pipe/dockerDesktopLinuxEngine + # + # Windows Podman [https://podman.io] (localhost only): + # npipe:////./pipe/docker_engine + # # Linux (localhost only): # unix:///var/run/docker.sock + # # TCP (Outside container): # tcp://localhost:2375 + # # TCP (Inside a container): - # tcp://host.docker.internal:2375 + # tcp://host.docker.internal:2375 URL: "unix:///var/run/docker.sock" \ No newline at end of file diff --git a/docker-connector/src/com/axonivy/connector/docker/IvyDockerClient.java b/docker-connector/src/com/axonivy/connector/docker/IvyDockerClient.java index 34b1107..7662175 100644 --- a/docker-connector/src/com/axonivy/connector/docker/IvyDockerClient.java +++ b/docker-connector/src/com/axonivy/connector/docker/IvyDockerClient.java @@ -34,13 +34,10 @@ private static DockerClient createDockerClient() { var dockerUrl = Ivy.var().get("Docker.URL"); var config = DefaultDockerClientConfig.createDefaultConfigBuilder() .withDockerHost(dockerUrl) -// .withDockerTlsVerify(true) -// .withDockerCertPath("C:\\Users\\rwei.ZUGPCRWEI2\\AppData\\Local\\Docker\\pki") .build(); var httpClient = new ApacheDockerHttpClient.Builder() .dockerHost(config.getDockerHost()) -// .sslConfig(config.getSSLConfig()) .maxConnections(100) .connectionTimeout(Duration.ofSeconds(30)) .responseTimeout(Duration.ofSeconds(45)) @@ -113,5 +110,4 @@ public void copyToContainer(Path hostPath, String containerId, String containerP .withRemotePath(containerPath) .exec(); } - } From fa2e0f9829ef2632c65ab02deef682b0ea56d57c Mon Sep 17 00:00:00 2001 From: Reto Weiss Date: Thu, 16 Nov 2023 12:15:21 +0100 Subject: [PATCH 8/8] Fix connection lost problem with PodMan --- .../processes/dockerDemo.p.json | 2 +- .../connector/docker/IvyDockerClient.java | 40 +++++++++++++++---- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/docker-connector-demo/processes/dockerDemo.p.json b/docker-connector-demo/processes/dockerDemo.p.json index b4e8383..5f58bb7 100644 --- a/docker-connector-demo/processes/dockerDemo.p.json +++ b/docker-connector-demo/processes/dockerDemo.p.json @@ -103,7 +103,7 @@ }, { "id" : "f9", "type" : "SubProcessCall", - "name" : "docker", + "name" : "Remove Container", "config" : { "processCall" : "docker:removeContainer(String)", "call" : { diff --git a/docker-connector/src/com/axonivy/connector/docker/IvyDockerClient.java b/docker-connector/src/com/axonivy/connector/docker/IvyDockerClient.java index 7662175..0ab815b 100644 --- a/docker-connector/src/com/axonivy/connector/docker/IvyDockerClient.java +++ b/docker-connector/src/com/axonivy/connector/docker/IvyDockerClient.java @@ -7,6 +7,8 @@ import java.util.Optional; import java.util.stream.Collectors; +import org.apache.hc.core5.http.NoHttpResponseException; + import com.github.dockerjava.api.DockerClient; import com.github.dockerjava.api.command.CreateContainerCmd; import com.github.dockerjava.api.command.ListContainersCmd; @@ -23,7 +25,11 @@ public class IvyDockerClient { private DockerClient client; private IvyDockerClient() { - client = createDockerClient(); + try { + client = createDockerClient(); + } catch (Exception ex) { + Ivy.log().error("Could not create docker client", ex); + } } public static IvyDockerClient instance() { @@ -61,21 +67,21 @@ public ListContainersCmd listContainersCmd() { return client.listContainersCmd(); } + public void startContainer(String id) { + retry(() -> client.startContainerCmd(id).exec()); + Ivy.log().info("Container "+id+" started"); + } + public void stopContainer(String id) { - client.stopContainerCmd(id).exec(); + retry(() -> client.stopContainerCmd(id).exec()); Ivy.log().info("Container "+id+" stopped"); } public void removeContainer(String id) { - client.removeContainerCmd(id).exec(); + retry(() -> client.removeContainerCmd(id).exec()); Ivy.log().info("Container "+id+" removed"); } - public void startContainer(String id) { - client.startContainerCmd(id).exec(); - Ivy.log().info("Container "+id+" started"); - } - public void executeInContainer(String id, String... command) { var cmd = client.execCreateCmd(id) .withCmd(command) @@ -110,4 +116,22 @@ public void copyToContainer(Path hostPath, String containerId, String containerP .withRemotePath(containerPath) .exec(); } + + private void retry(Runnable r) { + int retry = 0; + while (true) { + try { + r.run(); + return; + } catch (RuntimeException ex) { + if (! (ex.getCause() instanceof NoHttpResponseException)) { + throw ex; + } + retry++; + if (retry >= 3) { + throw ex; + } + } + } + } }