Skip to content

Commit

Permalink
added docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanlukas committed Apr 19, 2024
1 parent a828503 commit 39b91a6
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 45 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/mvn-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ jobs:
maven-auto-release-after-close: true
github-token: ${{ secrets.GITHUB_TOKEN }}
id: release

- name: Push all web modeler cli images
run: docker push -a -q ghcr.io/camunda-community-hub/web-modeler-java-client/web-modeler-cli
- if: github.event.release
name: Attach artifacts to GitHub Release (Release only)
uses: actions/upload-release-asset@v1
Expand Down
8 changes: 8 additions & 0 deletions web-modeler-openapi-cli/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM openjdk:21
# install web modeler cli to a nice location
WORKDIR /opt
RUN mkdir web-modeler-cli
WORKDIR /opt/web-modeler-cli
ADD target/web-modeler-openapi-cli-1.0.1-SNAPSHOT-jar-with-dependencies.jar web-modeler-cli.jar
# set the jar as entrypoint
ENTRYPOINT ["java", "-jar", "/opt/web-modeler-cli/web-modeler-cli.jar"]
30 changes: 28 additions & 2 deletions web-modeler-openapi-cli/pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
Expand All @@ -11,7 +12,6 @@
<artifactId>web-modeler-openapi-cli</artifactId>



<dependencies>
<dependency>
<groupId>org.camunda.community.webmodeler</groupId>
Expand Down Expand Up @@ -88,6 +88,32 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>docker-build</id>
<phase>deploy</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>docker</executable>
<workingDirectory>${project.basedir}</workingDirectory>
<arguments>
<argument>build</argument>
<argument>-t</argument>
<argument>ghcr.io/camunda-community-hub/web-modeler-java-client/web-modeler-cli:${project.version}</argument>
<argument>-t</argument>
<argument>ghcr.io/camunda-community-hub/web-modeler-java-client/web-modeler-cli:latest</argument>
<argument>.</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,69 +24,71 @@
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;

@Command(description = "Web Modeler CLI", mixinStandardHelpOptions = true)
@Command(
description = "Web Modeler CLI",
mixinStandardHelpOptions = true,
subcommands = {
InfoCommand.class,
ListProjectsCommand.class,
ListFilesCommand.class,
DownloadFileCommand.class,
DownloadProjectCommand.class
})
public class CommandLineApp {

public static final int MAX_PAGE_SIZE = 50;

@Option(
names = {"--token", "-t"},
description = "JWT token",
scope = CommandLine.ScopeType.INHERIT)
@Deprecated
String token;

@Option(
names = {"--basePath", "-b", "--baseUrl"},
description = "base url of API (default to Camunda Modeler Saas url)",
scope = CommandLine.ScopeType.INHERIT,
defaultValue = "${CAMUNDA_MODELER_CLIENT_BASEURL:-https://modeler.cloud.camunda.io}")
defaultValue = "${CAMUNDA_MODELER_CLIENT_BASEURL:-https://modeler.cloud.camunda.io}",
required = true)
String baseUrl;

@Option(
names = {"--authUrl"},
description = "auth url of API (default to Camunda Saas auth url)",
scope = CommandLine.ScopeType.INHERIT,
defaultValue =
"${CAMUNDA_MODELER_CLIENT_AUTHURL:-https://login.cloud.camunda.io/oauth/token}")
"${CAMUNDA_MODELER_CLIENT_AUTHURL:-https://login.cloud.camunda.io/oauth/token}",
required = true)
String authUrl;

@Option(
names = {"--audience"},
description = "audience of API (default to Camunda Saas audience)",
scope = CommandLine.ScopeType.INHERIT,
defaultValue = "${CAMUNDA_MODELER_CLIENT_AUDIENCE:-api.cloud.camunda.io}")
defaultValue = "${CAMUNDA_MODELER_CLIENT_AUDIENCE:-api.cloud.camunda.io}",
required = true)
String audience;

@Option(
names = {"--clientId"},
description = "client id",
scope = CommandLine.ScopeType.INHERIT,
defaultValue = "${CAMUNDA_MODELER_CLIENT_CLIENTID}")
defaultValue = "${CAMUNDA_MODELER_CLIENT_CLIENTID}",
required = true)
String clientId;

@Option(
names = {"--clientSecret"},
description = "client secret",
scope = CommandLine.ScopeType.INHERIT,
defaultValue = "${CAMUNDA_MODELER_CLIENT_CLIENTSECRET}")
defaultValue = "${CAMUNDA_MODELER_CLIENT_CLIENTSECRET}",
required = true)
String clientSecret;

@Option(
names = {"--authType"},
description = "auth type, only required for self-managed (default to KEYCLOAK)",
scope = CommandLine.ScopeType.INHERIT,
defaultValue = "${CAMUNDA_MODELER_CLIENT_AUTHTYPE:-KEYCLOAK}")
defaultValue = "${CAMUNDA_MODELER_CLIENT_AUTHTYPE:-KEYCLOAK}",
required = true)
Type authType;

public static void main(String[] args) {
new CommandLine(new CommandLineApp())
.addSubcommand(InfoCommand.class)
.addSubcommand(ListProjectsCommand.class)
.addSubcommand(ListFilesCommand.class)
.addSubcommand(DownloadFileCommand.class)
.addSubcommand(DownloadProjectCommand.class)
.execute(args);
new CommandLine(new CommandLineApp()).execute(args);
}

private JsonMapper jsonMapper() {
Expand Down Expand Up @@ -143,27 +145,19 @@ private boolean isSaas() {
}

private ApiClient buildApiClient() {
if (token != null) {
// legacy
ApiClient apiClient = new ApiClient();
apiClient.setBasePath(baseUrl);
apiClient.setBearerToken(token);
return apiClient;
} else {
JsonMapper jsonMapper = jsonMapper();
JwtCredential webModelerCredential = webModelerCredential();
JwtConfig jwtConfig = jwtConfig(webModelerCredential);
IdentityConfiguration identityConfiguration = identityConfiguration();
Identity identity = identity(identityConfiguration);
IdentityContainer identityContainer = identityContainer(identity, identityConfiguration);
IdentityConfig identityConfig = identityConfig(identityContainer);
return ApiClientFactory.getInstance()
.get(
new ApiClientConfiguration(
baseUrl,
new WebModelerAuthInterceptor(
authentication(jsonMapper, jwtConfig, identityConfig))));
}
JsonMapper jsonMapper = jsonMapper();
JwtCredential webModelerCredential = webModelerCredential();
JwtConfig jwtConfig = jwtConfig(webModelerCredential);
IdentityConfiguration identityConfiguration = identityConfiguration();
Identity identity = identity(identityConfiguration);
IdentityContainer identityContainer = identityContainer(identity, identityConfiguration);
IdentityConfig identityConfig = identityConfig(identityContainer);
return ApiClientFactory.getInstance()
.get(
new ApiClientConfiguration(
baseUrl,
new WebModelerAuthInterceptor(
authentication(jsonMapper, jwtConfig, identityConfig))));
}

protected CollaboratorsApi buildCollaboratorsClient() {
Expand Down

0 comments on commit 39b91a6

Please sign in to comment.