Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
fix(stack): update compose deployment service (#73)
Browse files Browse the repository at this point in the history
Co-authored-by: Andreas Riepl <[email protected]>
  • Loading branch information
DaAnda97 and DaAnda97 authored Dec 6, 2023
1 parent 75c07ca commit 126a6d9
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 30 deletions.
20 changes: 20 additions & 0 deletions .run/DeploymentServiceApplication.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="DeploymentServiceApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot" nameIsGenerated="true">
<module name="deployment-service" />
<option name="SPRING_BOOT_MAIN_CLASS" value="io.miranum.platform.deploymentservice.DeploymentServiceApplication" />
<extension name="net.ashald.envfile">
<option name="IS_ENABLED" value="true" />
<option name="IS_SUBST" value="false" />
<option name="IS_PATH_MACRO_SUPPORTED" value="false" />
<option name="IS_IGNORE_MISSING_FILES" value="false" />
<option name="IS_ENABLE_EXPERIMENTAL_INTEGRATIONS" value="false" />
<ENTRIES>
<ENTRY IS_ENABLED="true" PARSER="runconfig" IS_EXECUTABLE="false" />
<ENTRY IS_ENABLED="true" PARSER="env" IS_EXECUTABLE="false" PATH="platform-stack/.env" />
</ENTRIES>
</extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
3 changes: 2 additions & 1 deletion .run/Local.run.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Local" type="CompoundRunConfigurationType">
<toRun name="TasklistWebapp" type="MavenRunConfiguration" />
<toRun name="DeploymentServiceApplication" type="SpringBootApplicationConfigurationType" />
<toRun name="EngineTasklistApplication" type="SpringBootApplicationConfigurationType" />
<toRun name="S3IntegrationApplication" type="SpringBootApplicationConfigurationType" />
<toRun name="SchemaRegistryApplication" type="SpringBootApplicationConfigurationType" />
<method v="2" />
</configuration>
</component>
</component>
18 changes: 17 additions & 1 deletion .run/PlatformStack.run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,20 @@
</deployment>
<method v="2" />
</configuration>
</component>
<configuration default="false" name="PlatformStack" type="docker-deploy" factoryName="docker-compose.yml" server-name="Docker">
<deployment type="docker-compose.yml">
<settings>
<option name="envFilePath" value="" />
<option name="profiles">
<list>
<option value="engine" />
</list>
</option>
<option name="sourceFilePath" value="platform-stack/docker-compose.yml" />
<option name="upForceRecreate" value="true" />
<option name="upRemoveOrphans" value="true" />
</settings>
</deployment>
<method v="2" />
</configuration>
</component>
5 changes: 3 additions & 2 deletions .run/PlatformStackDev.run.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="PlatformStack" type="docker-deploy" factoryName="docker-compose.yml" server-name="Docker">
<configuration default="false" name="PlatformStackDev" type="docker-deploy" factoryName="docker-compose.yml" server-name="Docker">
<deployment type="docker-compose.yml">
<settings>
<option name="envFilePath" value="" />
<option name="removeVolumesOnComposeDown" value="true" />
<option name="sourceFilePath" value="platform-stack/docker-compose.yml" />
<option name="upForceRecreate" value="true" />
<option name="upRemoveOrphans" value="true" />
</settings>
</deployment>
<method v="2" />
</configuration>
</component>
</component>
20 changes: 18 additions & 2 deletions platform-stack/.env
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#
MIRANUM_PLATFORM_VERSION=0.3.0-SNAPSHOT
# General
#
MIRANUM_PLATFORM_VERSION=0.3.1-SNAPSHOT
LOCAL_DATASOURCE_USERNAME=postgres
LOCAL_DATASOURCE_PASSWORD=changeME!234
SSO_DATASOURCE_DB=keycloak

#
# POSTGRES SETUP

#
LOCAL_DB_VENDOR=postgres
LOCAL_KEYCLOAK_DB_VENDOR=postgres
LOCAL_JDBC_BASE_URL=jdbc:postgresql://localhost:5432/
Expand Down Expand Up @@ -66,3 +69,16 @@ S3INTEGRATION_DATASOURCE_PASSWORD=${LOCAL_DATASOURCE_PASSWORD}
S3INTEGRATION_DATASOURCE_URL=${LOCAL_JDBC_BASE_URL}${S3INTEGRATION_DATASOURCE_DB}
S3INTEGRATION_DATASOURCE_DRIVERCLASSNAME=org.postgresql.Driver
S3INTEGRATION_DATABASE_PLATFORM=io.miranum.integration.s3.infrastructure.dialect.NoToastPostgresSQLDialect

#
# Deployment
#
MIRANUM_DEPLOYMENT_SERVICE_PORT=8092
MIRANUM_DEPLOYMENT_SERVER_BPMN_TEST_URL=http://localhost
MIRANUM_DEPLOYMENT_SERVER_BPMN_TEST_PORT=8090
MIRANUM_DEPLOYMENT_SERVER_DMN_TEST_URL=http://localhost
MIRANUM_DEPLOYMENT_SERVER_DMN_TEST_PORT=8090
MIRANUM_DEPLOYMENT_SERVER_FORM_TEST_URL=http://localhost
MIRANUM_DEPLOYMENT_SERVER_FORM_TEST_PORT=8091
MIRANUM_DEPLOYMENT_SERVER_CONFIG_TEST_URL=http://localhost
MIRANUM_DEPLOYMENT_SERVER_CONFIG_TEST_PORT=8091
7 changes: 4 additions & 3 deletions platform-stack/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ services:
deployment:
image: miragon/miranum-platform-deployment-service:${MIRANUM_PLATFORM_VERSION}
container_name: miranum-deployment
profiles:
- engine
ports:
- "8092:8080"
restart: unless-stopped
Expand All @@ -90,8 +92,8 @@ services:
environment:
IO_MIRANUM_DEPLOYMENTSERVER_REST_TARGETS_TEST_BPMN: http://host.docker.internal:8090/rest/deployment
IO_MIRANUM_DEPLOYMENTSERVER_REST_TARGETS_TEST_DMN: http://host.docker.internal:8090/rest/deployment
IO_MIRANUM_DEPLOYMENTSERVER_REST_TARGETS_TEST_FORM: http://host.docker.internal:8090/rest/deployment
IO_MIRANUM_DEPLOYMENTSERVER_REST_TARGETS_TEST_CONFIG: http://host.docker.internal:8090/rest/deployment
IO_MIRANUM_DEPLOYMENTSERVER_REST_TARGETS_TEST_FORM: http://host.docker.internal:8091/deployment
IO_MIRANUM_DEPLOYMENTSERVER_REST_TARGETS_TEST_CONFIG: http://host.docker.internal:8091/deployment
extra_hosts:
- "host.docker.internal:host-gateway"
networks:
Expand Down Expand Up @@ -161,7 +163,6 @@ services:
container_name: postgres
volumes:
- ./postgres/:/docker-entrypoint-initdb.d/
- ./data:/var/lib/postgresql/data
ports:
- "5432:5432"
restart: unless-stopped
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
<name>miranum-platform</name>
<packaging>pom</packaging>
<description>Miranum Platform</description>
<url>https://github.com/FlowSquad/miranum-platform</url>
<url>https://github.com/Miragon/miranum-platform</url>

<properties>
<revision>0.3.0-SNAPSHOT</revision>
<revision>0.3.1-SNAPSHOT</revision>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<java.version>17</java.version>
Expand Down
24 changes: 20 additions & 4 deletions services/deployment-service/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
io:
miranum:
deploymentserver:
rest:
server:
port: '${MIRANUM_DEPLOYMENT_SERVICE_PORT:8080}'

io.miranum.deploymentserver.rest:
enabled: true
targets:
dev:
bpmn: '${MIRANUM_DEPLOYMENT_SERVER_BPMN_DEV_URL}:${MIRANUM_DEPLOYMENT_SERVER_BPMN_DEV_PORT}/rest/deployment'
dmn: '${MIRANUM_DEPLOYMENT_SERVER_DMN_DEV_URL}:${MIRANUM_DEPLOYMENT_SERVER_DMN_DEV_PORT}/rest/deployment'
form: '${MIRANUM_DEPLOYMENT_SERVER_FORM_DEV_URL}:${MIRANUM_DEPLOYMENT_SERVER_FORM_DEV_PORT}/rest/deployment'
config: '${MIRANUM_DEPLOYMENT_SERVER_CONFIG_DEV_URL}:${MIRANUM_DEPLOYMENT_SERVER_CONFIG_DEV_PORT}/rest/deployment'
test:
bpmn: '${MIRANUM_DEPLOYMENT_SERVER_BPMN_TEST_URL}:${MIRANUM_DEPLOYMENT_SERVER_BPMN_TEST_PORT}/rest/deployment'
dmn: '${MIRANUM_DEPLOYMENT_SERVER_DMN_TEST_URL}:${MIRANUM_DEPLOYMENT_SERVER_DMN_TEST_PORT}/rest/deployment'
form: '${MIRANUM_DEPLOYMENT_SERVER_FORM_TEST_URL}:${MIRANUM_DEPLOYMENT_SERVER_FORM_TEST_PORT}/rest/deployment'
config: '${MIRANUM_DEPLOYMENT_SERVER_CONFIG_TEST_URL}:${MIRANUM_DEPLOYMENT_SERVER_CONFIG_TEST_PORT}/rest/deployment'
prod:
bpmn: '${MIRANUM_DEPLOYMENT_SERVER_BPMN_PROD_URL}:${MIRANUM_DEPLOYMENT_SERVER_BPMN_PROD_PORT}/rest/deployment'
dmn: '${MIRANUM_DEPLOYMENT_SERVER_DMN_PROD_URL}:${MIRANUM_DEPLOYMENT_SERVER_DMN_PROD_PORT}/rest/deployment'
form: '${MIRANUM_DEPLOYMENT_SERVER_FORM_PROD_URL}:${MIRANUM_DEPLOYMENT_SERVER_FORM_PROD_PORT}/rest/deployment'
config: '${MIRANUM_DEPLOYMENT_SERVER_CONFIG_PROD_URL}:${MIRANUM_DEPLOYMENT_SERVER_CONFIG_PROD_PORT}/rest/deployment'
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,27 @@ public class SchemaDeploymentReceiver implements MiranumDeploymentReceiver {

@Override
public void deploy(final Deployment deployment, final List<String> tags) {
// process configs and forms are both json schemas and saved the same way
if (deployment.getType().equalsIgnoreCase("form") || deployment.getType().equalsIgnoreCase("config")) {
try {
final JsonNode jsonSchema = this.objectMapper.readTree(deployment.getFile());
this.deployJsonSchema(jsonSchema, deployment.getNamespace(), tags);
log.info("Deployed json schema {} of type {}", deployment.getFilename(), deployment.getType());
} catch (final IOException e) {
log.error("Could not parse schema {}", deployment.getFilename(), e);
throw new DeploymentFailedException("Could not parse schema " + deployment.getFilename());
try {
final String namespace = deployment.getNamespace();
final JsonNode jsonNode = this.objectMapper.readTree(deployment.getFile());
final String schemaRef = Optional.of(jsonNode.get("key")).map(JsonNode::asText)
.orElseThrow(() -> new DeploymentFailedException("No key found in schema " + jsonNode.get("key")));

switch (deployment.getType().toLowerCase()) {
case "form":
final JsonNode schema = jsonNode.get("schema");
this.saveSchemaUseCase.saveSchema(new SaveSchemaInCommand(namespace, schemaRef, tags, schema));
break;
case "config":
this.saveSchemaUseCase.saveSchema(new SaveSchemaInCommand(namespace, schemaRef, tags, jsonNode));
break;
default:
log.info("Ignoring deployment of type {}", deployment.getType().toLowerCase());
}
} catch (final IOException e) {
log.error("Could not parse schema {}", deployment.getFilename(), e);
throw new DeploymentFailedException("Could not parse schema " + deployment.getFilename());
}
}

private void deployJsonSchema(final JsonNode schema, final String namespace, final List<String> tags) {
final String schemaRef = Optional.of(schema.get("key")).map(JsonNode::asText)
.orElseThrow(() -> new DeploymentFailedException("No key found in schema " + schema.get("key")));
final SaveSchemaInCommand saveSchemaInCommand = new SaveSchemaInCommand(namespace, schemaRef, tags, schema);
this.saveSchemaUseCase.saveSchema(saveSchemaInCommand);
}
}

0 comments on commit 126a6d9

Please sign in to comment.