From f286a183e1707b5cd73cae7bce4d82b3e62bbf1f Mon Sep 17 00:00:00 2001 From: Moti Asayag Date: Mon, 20 Mar 2023 21:31:52 +0200 Subject: [PATCH] Decouple examples from service The purpose of this PR is to decouple the user's workflows from being built into the workflow-service by using the PropertiesLauncher as the Start-Class of the application. Extra dependencies can be provided via system property `loader.path`. In addition, to satisfy all runtime dependencies, the workflow-example is being built with a plugin to include all of its dependencies in a single jar. For local development, a local profile was added to include the workflow-examples dependency in the service's path: ``` mvn clean install -Plocal ``` Signed-off-by: Moti Asayag --- Makefile | 4 +++- docker-compose/docker-compose.yml | 5 +++-- workflow-examples/pom.xml | 21 +++++++++++++++++++++ workflow-examples/start_workflow_service.sh | 4 +++- workflow-service/Dockerfile | 3 ++- workflow-service/pom.xml | 21 ++++++++++++++++----- workflow-service/start_workflow_service.sh | 4 +++- 7 files changed, 51 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index fbd8195a7..c44b14272 100644 --- a/Makefile +++ b/Makefile @@ -182,7 +182,9 @@ docker-stop: ## Stop notification and workflow services JAVA_ARGS = -Dspring.profiles.active=local run-workflow-service: java-checks ## Run local workflow service - java -jar $(JAVA_ARGS) workflow-service/target/workflow-service-$(VERSION).jar + java -jar $(JAVA_ARGS) \ + -Dloader.path=workflow-examples/target/workflow-examples-$(VERSION)-jar-with-dependencies.jar \ + workflow-service/target/workflow-service-$(VERSION).jar run-notification-service: java-checks ## Run local notification service java -jar $(JAVA_ARGS) notification-service/target/notification-service-$(VERSION).jar diff --git a/docker-compose/docker-compose.yml b/docker-compose/docker-compose.yml index 924f81ace..d27d08bd4 100644 --- a/docker-compose/docker-compose.yml +++ b/docker-compose/docker-compose.yml @@ -12,12 +12,13 @@ services: workflow-service: build: - context: ../workflow-service - dockerfile: ./Dockerfile + context: ../ + dockerfile: ./workflow-service/Dockerfile container_name: workflow-service ports: - 9000:8080 environment: - SPRING_PROFILES_ACTIVE=local + - LOADER_PATH=./workflow-examples.jar depends_on: - notification-service \ No newline at end of file diff --git a/workflow-examples/pom.xml b/workflow-examples/pom.xml index b2958b37b..7be28749a 100644 --- a/workflow-examples/pom.xml +++ b/workflow-examples/pom.xml @@ -37,11 +37,13 @@ org.springframework spring-context ${spring.framework.version} + provided org.springframework spring-web ${spring.framework.version} + provided dev.parodos @@ -112,6 +114,25 @@ html + + org.apache.maven.plugins + maven-assembly-plugin + 3.5.0 + + + jar-with-dependencies + + + + + assemble-all + package + + single + + + + \ No newline at end of file diff --git a/workflow-examples/start_workflow_service.sh b/workflow-examples/start_workflow_service.sh index 913a7cb81..84d78fa2c 100755 --- a/workflow-examples/start_workflow_service.sh +++ b/workflow-examples/start_workflow_service.sh @@ -1 +1,3 @@ -java -jar -Dspring.profiles.active=local ../workflow-service/target/workflow-service-1.0.3-SNAPSHOT.jar +java -jar -Dspring.profiles.active=local \ + -Dloader.path=../workflow-examples/target/workflow-examples-1.0.3-SNAPSHOT-jar-with-dependencies.jar \ + ../workflow-service/target/workflow-service-1.0.3-SNAPSHOT.jar diff --git a/workflow-service/Dockerfile b/workflow-service/Dockerfile index 6748ca9b2..543442fa8 100644 --- a/workflow-service/Dockerfile +++ b/workflow-service/Dockerfile @@ -2,7 +2,8 @@ FROM registry.access.redhat.com/ubi9/openjdk-11-runtime WORKDIR /app -COPY target/*.jar ./workflow-service.jar +COPY workflow-service/target/*.jar ./workflow-service.jar +COPY workflow-examples/target/*jar-with-dependencies.jar ./workflow-examples.jar EXPOSE 8080 diff --git a/workflow-service/pom.xml b/workflow-service/pom.xml index 73937f972..d7accc5b2 100644 --- a/workflow-service/pom.xml +++ b/workflow-service/pom.xml @@ -126,11 +126,6 @@ workflow-engine ${revision} - - dev.parodos - workflow-examples - ${revision} - @@ -214,6 +209,9 @@ org.springframework.boot spring-boot-maven-plugin ${springframework.boot.version} + + ZIP + @@ -224,4 +222,17 @@ + + + + local + + + dev.parodos + workflow-examples + ${revision} + + + + diff --git a/workflow-service/start_workflow_service.sh b/workflow-service/start_workflow_service.sh index 5a7a0fd89..7c0f25abb 100755 --- a/workflow-service/start_workflow_service.sh +++ b/workflow-service/start_workflow_service.sh @@ -1 +1,3 @@ -java -jar -Dspring.profiles.active=local target/workflow-service-1.0.3-SNAPSHOT.jar +java -jar -Dspring.profiles.active=local \ + -Dloader.path=../workflow-examples/target/workflow-examples-1.0.3-SNAPSHOT-jar-with-dependencies.jar \ + target/workflow-service-1.0.3-SNAPSHOT.jar \ No newline at end of file