From dfcbee93c4ebebc9745ad620f3c2ceef47250717 Mon Sep 17 00:00:00 2001 From: Michael Rasch Date: Mon, 28 Apr 2025 20:54:59 -0400 Subject: [PATCH 1/8] Separate Main Class to New Module --- pom.xml | 1 + .../.github/workflows/postman.yml | 0 {server => registry-server-runner}/Dockerfile | 0 registry-server-runner/pom.xml | 40 +++++++++++++++++++ .../postman-docker-compose.yml | 0 .../postman/collection/collection.json | 0 .../postman/environment/env.json | 0 .../com/michael/container/RegistryRunner.java | 9 +++++ .../src/main/resources/application.properties | 6 +++ .../standalone-docker-compose.yml | 0 .../com/michael/container/RegistryRunner.java | 9 ----- .../michael/container/auto/ScanPackages.java | 2 +- .../src/main/resources/application.properties | 5 --- .../com/michael/container/RegistryRunner.java | 11 +++++ 14 files changed, 68 insertions(+), 15 deletions(-) rename {server => registry-server-runner}/.github/workflows/postman.yml (100%) rename {server => registry-server-runner}/Dockerfile (100%) create mode 100644 registry-server-runner/pom.xml rename {server => registry-server-runner}/postman-docker-compose.yml (100%) rename {server => registry-server-runner}/postman/collection/collection.json (100%) rename {server => registry-server-runner}/postman/environment/env.json (100%) create mode 100644 registry-server-runner/src/main/java/com/michael/container/RegistryRunner.java create mode 100644 registry-server-runner/src/main/resources/application.properties rename {server => registry-server-runner}/standalone-docker-compose.yml (100%) delete mode 100644 server/src/main/java/com/michael/container/RegistryRunner.java create mode 100644 server/src/test/java/com/michael/container/RegistryRunner.java diff --git a/pom.xml b/pom.xml index 6d02a17..80620be 100644 --- a/pom.xml +++ b/pom.xml @@ -18,6 +18,7 @@ server-bom server + registry-server-runner diff --git a/server/.github/workflows/postman.yml b/registry-server-runner/.github/workflows/postman.yml similarity index 100% rename from server/.github/workflows/postman.yml rename to registry-server-runner/.github/workflows/postman.yml diff --git a/server/Dockerfile b/registry-server-runner/Dockerfile similarity index 100% rename from server/Dockerfile rename to registry-server-runner/Dockerfile diff --git a/registry-server-runner/pom.xml b/registry-server-runner/pom.xml new file mode 100644 index 0000000..59b5ff4 --- /dev/null +++ b/registry-server-runner/pom.xml @@ -0,0 +1,40 @@ + + + 4.0.0 + + com.michael + service-container-parent + 1.0.0 + + + registry-server-runner + + + 23 + 23 + UTF-8 + + + + + + com.michael + service-container-parent + 1.0.0 + pom + import + + + + + + + com.michael + service-container-server + 1.0.0 + + + + \ No newline at end of file diff --git a/server/postman-docker-compose.yml b/registry-server-runner/postman-docker-compose.yml similarity index 100% rename from server/postman-docker-compose.yml rename to registry-server-runner/postman-docker-compose.yml diff --git a/server/postman/collection/collection.json b/registry-server-runner/postman/collection/collection.json similarity index 100% rename from server/postman/collection/collection.json rename to registry-server-runner/postman/collection/collection.json diff --git a/server/postman/environment/env.json b/registry-server-runner/postman/environment/env.json similarity index 100% rename from server/postman/environment/env.json rename to registry-server-runner/postman/environment/env.json diff --git a/registry-server-runner/src/main/java/com/michael/container/RegistryRunner.java b/registry-server-runner/src/main/java/com/michael/container/RegistryRunner.java new file mode 100644 index 0000000..402a065 --- /dev/null +++ b/registry-server-runner/src/main/java/com/michael/container/RegistryRunner.java @@ -0,0 +1,9 @@ +package com.michael.container; + +@SpringBootApplication +public class RegistryRunner { + + public static void main(String[] args) { + SpringApplication.run(RegistryRunner.class); + } +} diff --git a/registry-server-runner/src/main/resources/application.properties b/registry-server-runner/src/main/resources/application.properties new file mode 100644 index 0000000..0200aa8 --- /dev/null +++ b/registry-server-runner/src/main/resources/application.properties @@ -0,0 +1,6 @@ +service.registry.enabled=true +server.port=9095 +server.servlet.context-path=/service-registry/api/v2 +spring.redis.host=${REDIS_HOST} +spring.redis.port=${REDIS_PORT} +etcd.leader.key=/leader \ No newline at end of file diff --git a/server/standalone-docker-compose.yml b/registry-server-runner/standalone-docker-compose.yml similarity index 100% rename from server/standalone-docker-compose.yml rename to registry-server-runner/standalone-docker-compose.yml diff --git a/server/src/main/java/com/michael/container/RegistryRunner.java b/server/src/main/java/com/michael/container/RegistryRunner.java deleted file mode 100644 index 427d0fc..0000000 --- a/server/src/main/java/com/michael/container/RegistryRunner.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.michael.container; - -// @SpringBootApplication -// public class RegistryRunner { -// -// public static void main(String[] args) { -// SpringApplication.run(RegistryRunner.class); -// } -// } diff --git a/server/src/main/java/com/michael/container/auto/ScanPackages.java b/server/src/main/java/com/michael/container/auto/ScanPackages.java index 89cdea6..62462cb 100644 --- a/server/src/main/java/com/michael/container/auto/ScanPackages.java +++ b/server/src/main/java/com/michael/container/auto/ScanPackages.java @@ -7,6 +7,6 @@ @ComponentScan("com.michael.container") @Configuration -@ConditionalOnProperty(value = "service.registry.enabled", havingValue = "true", matchIfMissing = true) +@ConditionalOnProperty(value = "service.registry.enabled", havingValue = "true") @EnableRedisRepositories(basePackages = "com.michael.container") public class ScanPackages {} diff --git a/server/src/main/resources/application.properties b/server/src/main/resources/application.properties index 662385c..b3da2ef 100644 --- a/server/src/main/resources/application.properties +++ b/server/src/main/resources/application.properties @@ -1,8 +1,3 @@ -server.port=9095 -server.servlet.context-path=/service-registry/api/v2 - etcd.urls=${ETCD_URLS} -etcd.leader.key=/leader - spring.redis.host=${REDIS_HOST} spring.redis.port=${REDIS_PORT} \ No newline at end of file diff --git a/server/src/test/java/com/michael/container/RegistryRunner.java b/server/src/test/java/com/michael/container/RegistryRunner.java new file mode 100644 index 0000000..0ccdb96 --- /dev/null +++ b/server/src/test/java/com/michael/container/RegistryRunner.java @@ -0,0 +1,11 @@ +package com.michael.container; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class RegistryRunner { + public static void main(String[] args) { + SpringApplication.run(RegistryRunner.class); + } +} From 49636f45568d28f7f370e9119c8ad61e8c662fe0 Mon Sep 17 00:00:00 2001 From: Michael Rasch Date: Mon, 28 Apr 2025 20:56:43 -0400 Subject: [PATCH 2/8] Moved .github back to root --- {registry-server-runner/.github => .github}/workflows/postman.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {registry-server-runner/.github => .github}/workflows/postman.yml (100%) diff --git a/registry-server-runner/.github/workflows/postman.yml b/.github/workflows/postman.yml similarity index 100% rename from registry-server-runner/.github/workflows/postman.yml rename to .github/workflows/postman.yml From af0ceee4f12016bcb7de3d8e7d60aaaa1e929a39 Mon Sep 17 00:00:00 2001 From: Michael Rasch Date: Mon, 28 Apr 2025 21:01:56 -0400 Subject: [PATCH 3/8] Fix .github and docker files --- .github/workflows/postman.yml | 4 ++-- registry-server-runner/Dockerfile | 2 +- registry-server-runner/postman-docker-compose.yml | 2 +- .../main/java/com/michael/container/RegistryRunner.java | 9 ++++++--- registry-server-runner/standalone-docker-compose.yml | 2 +- .../test/java/com/michael/container/RegistryRunner.java | 6 +++--- 6 files changed, 14 insertions(+), 11 deletions(-) diff --git a/.github/workflows/postman.yml b/.github/workflows/postman.yml index 660db18..9b45885 100644 --- a/.github/workflows/postman.yml +++ b/.github/workflows/postman.yml @@ -28,7 +28,7 @@ jobs: - name: Run Docker Compose uses: hoverkraft-tech/compose-action@v2.0.1 with: - compose-file: "./postman-docker-compose.yml" + compose-file: "./registry-server-runner/postman-docker-compose.yml" action: "up" - name: Run Application With Postman Tests @@ -38,5 +38,5 @@ jobs: - name: Clean up containers uses: hoverkraft-tech/compose-action@v2.0.1 with: - compose-file: "./postman-docker-compose.yml" + compose-file: "./registry-server-runner/postman-docker-compose.yml" action: "down" diff --git a/registry-server-runner/Dockerfile b/registry-server-runner/Dockerfile index 6835a57..075133d 100644 --- a/registry-server-runner/Dockerfile +++ b/registry-server-runner/Dockerfile @@ -1,6 +1,6 @@ FROM openjdk:23-jdk-slim RUN apt-get update && apt-get install -y curl -ARG JAR_FILE=target/*.jar +ARG JAR_FILE=./registry-server-runner/target/*.jar COPY ${JAR_FILE} app.jar EXPOSE 9095 ENTRYPOINT ["java", "-jar", "/app.jar"] diff --git a/registry-server-runner/postman-docker-compose.yml b/registry-server-runner/postman-docker-compose.yml index e29d0b4..7968443 100644 --- a/registry-server-runner/postman-docker-compose.yml +++ b/registry-server-runner/postman-docker-compose.yml @@ -46,7 +46,7 @@ services: - spring.profiles.active=automation build: context: .. - dockerfile: ../Dockerfile + dockerfile: ./registry-server-runner/Dockerfile ports: - "9095:9095" networks: diff --git a/registry-server-runner/src/main/java/com/michael/container/RegistryRunner.java b/registry-server-runner/src/main/java/com/michael/container/RegistryRunner.java index 402a065..39e4905 100644 --- a/registry-server-runner/src/main/java/com/michael/container/RegistryRunner.java +++ b/registry-server-runner/src/main/java/com/michael/container/RegistryRunner.java @@ -1,9 +1,12 @@ package com.michael.container; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + @SpringBootApplication public class RegistryRunner { - public static void main(String[] args) { - SpringApplication.run(RegistryRunner.class); - } + public static void main(String[] args) { + SpringApplication.run(RegistryRunner.class); + } } diff --git a/registry-server-runner/standalone-docker-compose.yml b/registry-server-runner/standalone-docker-compose.yml index 9bc728b..1d49d1d 100644 --- a/registry-server-runner/standalone-docker-compose.yml +++ b/registry-server-runner/standalone-docker-compose.yml @@ -49,7 +49,7 @@ services: - REDIS_PORT=6379 build: context: .. - dockerfile: ../Dockerfile + dockerfile: ./registry-server-runner/Dockerfile depends_on: redis: condition: service_healthy diff --git a/server/src/test/java/com/michael/container/RegistryRunner.java b/server/src/test/java/com/michael/container/RegistryRunner.java index 0ccdb96..e5596c3 100644 --- a/server/src/test/java/com/michael/container/RegistryRunner.java +++ b/server/src/test/java/com/michael/container/RegistryRunner.java @@ -5,7 +5,7 @@ @SpringBootApplication public class RegistryRunner { - public static void main(String[] args) { - SpringApplication.run(RegistryRunner.class); - } + public static void main(String[] args) { + SpringApplication.run(RegistryRunner.class); + } } From 8940a2f98d31d4621d8785e56a0d5eb56cbd07da Mon Sep 17 00:00:00 2001 From: Michael Rasch Date: Mon, 28 Apr 2025 21:07:35 -0400 Subject: [PATCH 4/8] Fixed scan issue with redis --- .../src/main/java/com/michael/container/auto/ScanPackages.java | 2 -- .../java/com/michael/container/config/RedisConfiguration.java | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/com/michael/container/auto/ScanPackages.java b/server/src/main/java/com/michael/container/auto/ScanPackages.java index 62462cb..3efb2af 100644 --- a/server/src/main/java/com/michael/container/auto/ScanPackages.java +++ b/server/src/main/java/com/michael/container/auto/ScanPackages.java @@ -3,10 +3,8 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; -import org.springframework.data.redis.repository.configuration.EnableRedisRepositories; @ComponentScan("com.michael.container") @Configuration @ConditionalOnProperty(value = "service.registry.enabled", havingValue = "true") -@EnableRedisRepositories(basePackages = "com.michael.container") public class ScanPackages {} diff --git a/server/src/main/java/com/michael/container/config/RedisConfiguration.java b/server/src/main/java/com/michael/container/config/RedisConfiguration.java index d1cf13e..ec052e2 100644 --- a/server/src/main/java/com/michael/container/config/RedisConfiguration.java +++ b/server/src/main/java/com/michael/container/config/RedisConfiguration.java @@ -17,10 +17,12 @@ import org.springframework.data.redis.listener.ChannelTopic; import org.springframework.data.redis.listener.PatternTopic; import org.springframework.data.redis.listener.RedisMessageListenerContainer; +import org.springframework.data.redis.repository.configuration.EnableRedisRepositories; import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; import org.springframework.data.redis.serializer.StringRedisSerializer; @Configuration +@EnableRedisRepositories(basePackages = "com.michael.container") public class RedisConfiguration { @Bean public RedisConnectionFactory redisConnectionFactory( From b73ba4b08038ce9b9ed4e748bb083b77407b9756 Mon Sep 17 00:00:00 2001 From: Michael Rasch Date: Mon, 28 Apr 2025 21:23:59 -0400 Subject: [PATCH 5/8] Packaging Fat Jar --- registry-server-runner/pom.xml | 17 +++++++++++++++++ .../postman-docker-compose.yml | 4 ++-- .../{RegistryRunner.java => Runner.java} | 4 ++-- 3 files changed, 21 insertions(+), 4 deletions(-) rename registry-server-runner/src/main/java/com/michael/container/{RegistryRunner.java => Runner.java} (74%) diff --git a/registry-server-runner/pom.xml b/registry-server-runner/pom.xml index 59b5ff4..91d4e67 100644 --- a/registry-server-runner/pom.xml +++ b/registry-server-runner/pom.xml @@ -37,4 +37,21 @@ + + + + org.springframework.boot + spring-boot-maven-plugin + 3.4.5 + + + + repackage + + + + + + + \ No newline at end of file diff --git a/registry-server-runner/postman-docker-compose.yml b/registry-server-runner/postman-docker-compose.yml index 7968443..95b4e6d 100644 --- a/registry-server-runner/postman-docker-compose.yml +++ b/registry-server-runner/postman-docker-compose.yml @@ -66,8 +66,8 @@ services: newman: image: postman/newman:alpine volumes: - - ./postman/environment/env.json:/etc/newman/environment.json - - ./postman/collection/collection.json:/etc/newman/collection.json + - ./registry-server-runner/postman/environment/env.json:/etc/newman/environment.json + - ./registry-server-runner/postman/collection/collection.json:/etc/newman/collection.json networks: - app-network depends_on: diff --git a/registry-server-runner/src/main/java/com/michael/container/RegistryRunner.java b/registry-server-runner/src/main/java/com/michael/container/Runner.java similarity index 74% rename from registry-server-runner/src/main/java/com/michael/container/RegistryRunner.java rename to registry-server-runner/src/main/java/com/michael/container/Runner.java index 39e4905..889a12d 100644 --- a/registry-server-runner/src/main/java/com/michael/container/RegistryRunner.java +++ b/registry-server-runner/src/main/java/com/michael/container/Runner.java @@ -4,9 +4,9 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication -public class RegistryRunner { +public class Runner { public static void main(String[] args) { - SpringApplication.run(RegistryRunner.class); + SpringApplication.run(Runner.class); } } From 63d6ea411d55e6628159e160acd03d225aa3ae07 Mon Sep 17 00:00:00 2001 From: Michael Rasch Date: Mon, 28 Apr 2025 21:28:33 -0400 Subject: [PATCH 6/8] Try fix compose-file --- .github/workflows/postman.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/postman.yml b/.github/workflows/postman.yml index 9b45885..e1f8470 100644 --- a/.github/workflows/postman.yml +++ b/.github/workflows/postman.yml @@ -38,5 +38,5 @@ jobs: - name: Clean up containers uses: hoverkraft-tech/compose-action@v2.0.1 with: - compose-file: "./registry-server-runner/postman-docker-compose.yml" + compose-file: "registry-server-runner/postman-docker-compose.yml" action: "down" From 43b682d8d99cdf12f86baf2cd1750b15db2bbf51 Mon Sep 17 00:00:00 2001 From: Michael Rasch Date: Mon, 28 Apr 2025 21:29:27 -0400 Subject: [PATCH 7/8] Docker compose up --- .github/workflows/postman.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/postman.yml b/.github/workflows/postman.yml index e1f8470..b57b382 100644 --- a/.github/workflows/postman.yml +++ b/.github/workflows/postman.yml @@ -33,10 +33,10 @@ jobs: - name: Run Application With Postman Tests run: | - docker compose -f postman-docker-compose.yml up --build --exit-code-from newman + docker compose -f ./registry-server-runner/postman-docker-compose.yml up --build --exit-code-from newman - name: Clean up containers uses: hoverkraft-tech/compose-action@v2.0.1 with: - compose-file: "registry-server-runner/postman-docker-compose.yml" + compose-file: "./registry-server-runner/postman-docker-compose.yml" action: "down" From 8c5043285b6bf10d0066bce692687c0693458e82 Mon Sep 17 00:00:00 2001 From: Michael Rasch Date: Mon, 28 Apr 2025 23:22:50 -0400 Subject: [PATCH 8/8] Fixed newman --- registry-server-runner/postman-docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/registry-server-runner/postman-docker-compose.yml b/registry-server-runner/postman-docker-compose.yml index 95b4e6d..24f6181 100644 --- a/registry-server-runner/postman-docker-compose.yml +++ b/registry-server-runner/postman-docker-compose.yml @@ -66,8 +66,8 @@ services: newman: image: postman/newman:alpine volumes: - - ./registry-server-runner/postman/environment/env.json:/etc/newman/environment.json - - ./registry-server-runner/postman/collection/collection.json:/etc/newman/collection.json + - ../registry-server-runner/postman/environment/env.json:/etc/newman/environment.json + - ../registry-server-runner/postman/collection/collection.json:/etc/newman/collection.json networks: - app-network depends_on: