diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 007dba7..0000000 --- a/Dockerfile +++ /dev/null @@ -1,5 +0,0 @@ -FROM adoptopenjdk/openjdk11 -VOLUME /tmp -VOLUME /X/attachments -COPY core/target/*.jar app.jar -ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"] diff --git a/README.md b/README.md index 058e7c5..38363cc 100644 --- a/README.md +++ b/README.md @@ -64,11 +64,11 @@ Misc: - Cache implemented - Zipkin tracing - Websocket implemented to show article/comment review status/notifications.. +- Docker-compose deploy/kubernetes Future: do more stuff - CQRS with event store/streaming - Spring Cloud Contract integration (WIP) -- Docker-compose deploy/kubernetes - Visitors log - IP, browser, etc - Centralized error reporting - Geo-Spatial query for visitors @@ -87,7 +87,7 @@ Future: do more stuff - JfrUnit ( WIP ) - ### Requirements -- JDK 17+ +- JDK 21+ - Lombok configured on IDE - http://ganeshtiwaridotcomdotnp.blogspot.com/2016/03/configuring-lombok-on-intellij.html - For eclipse, download the lombok jar, run it, and point to eclipse installation @@ -96,7 +96,17 @@ Future: do more stuff - Make sure docker is started and running - Run `$ sudo chmod 666 /var/run/docker.sock` if you get error like this "Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? (Details: [13] Permission denied)" -#### How to Run + +## Build and create docker image + +`sh build-docker-images.sh` + +## Run all apps and dependencies using docker-compose + +- Run ```docker compose -f docker/docker-compose.yml up``` at root to run all apps and dependencies and open localhost:8081 to access main app + + +## How to Run apps individually It contains following applications: @@ -110,21 +120,18 @@ It contains following applications: Option 1 - run with manually started KeyCloak, ActiveMQ and MySQL servers - Run ```mvn clean install``` at root -- Run ```docker-compose -f config/docker-compose.yml up``` at root to start docker containers +- Run ```docker compose -f docker/docker-compose-dev.yml up``` at root to start docker containers - Go to main-app folder and run ```mvn``` to start the application -Option 2 - automatically start KeyCloak, ActiveMQ and MySQL using TestContainer while application is starting -- Run ```mvn clean install``` at root -- Go to main-app folder and run ```mvn -Pdev,withTestContainer``` to start the application -Option 3 - run from IDE +Option 2 - run from IDE - import into your IDE and compile the full project and run the Application.java on main-app module - Update run configuration to run maven goal `wro4j:run` Before Launch. It should be after 'Build' ## Run Tests (use ./mvnw instead of mvn if you want to use maven wrapper) -## It uses TestContainers, which requires Docker to be installed locally. + Test uses TestContainers, which requires Docker to be installed locally. ##### Running full tests diff --git a/build-docker-images.sh b/build-docker-images.sh new file mode 100755 index 0000000..a477f16 --- /dev/null +++ b/build-docker-images.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +# full build with 5 threads +./mvnw -T 5 clean package install + +# create docker images out of build jar files using spring boot and packeto +./mvnw spring-boot:build-image-no-fork -pl content-checker/content-checker-service +./mvnw spring-boot:build-image-no-fork -pl email/email-service +./mvnw spring-boot:build-image-no-fork -pl trend/trend-service +./mvnw spring-boot:build-image-no-fork -pl main-app/main-webapp +./mvnw spring-boot:build-image-no-fork -pl main-app/report-service + +# list +docker image ls | grep gtapp diff --git a/content-checker/content-checker-service/pom.xml b/content-checker/content-checker-service/pom.xml index ad75dfd..e7fffef 100644 --- a/content-checker/content-checker-service/pom.xml +++ b/content-checker/content-checker-service/pom.xml @@ -74,6 +74,12 @@ org.springframework.boot spring-boot-maven-plugin + + gtapp-${project.name} + + true + + com.github.spotbugs @@ -95,10 +101,7 @@ - dev - - true - + local org.springdoc @@ -108,16 +111,8 @@ - dev - dev - - - - - prod - - prod - prod + local + local diff --git a/content-checker/content-checker-service/src/main/resources/application-default.yml b/content-checker/content-checker-service/src/main/resources/application-default.yml index 0a6f272..4617b5d 100644 --- a/content-checker/content-checker-service/src/main/resources/application-default.yml +++ b/content-checker/content-checker-service/src/main/resources/application-default.yml @@ -1,3 +1,3 @@ spring: profiles: - active: dev + active: local diff --git a/content-checker/content-checker-service/src/main/resources/application-dev.yml b/content-checker/content-checker-service/src/main/resources/application-dev.yml deleted file mode 100644 index a6c705b..0000000 --- a/content-checker/content-checker-service/src/main/resources/application-dev.yml +++ /dev/null @@ -1,6 +0,0 @@ -spring: - artemis: - host: ${ACTIVEMQ_ARTEMIS_HOST:localhost} - port: ${ACTIVEMQ_ARTEMIS_PORT:61616} - user: admin - password: admin diff --git a/content-checker/content-checker-service/src/main/resources/application.yml b/content-checker/content-checker-service/src/main/resources/application.yml index 56d7c55..a1263f5 100644 --- a/content-checker/content-checker-service/src/main/resources/application.yml +++ b/content-checker/content-checker-service/src/main/resources/application.yml @@ -6,6 +6,11 @@ spring: # Otherwise, it will be filled in by maven when building the WAR file # Either way, it can be overridden by `--spring.profiles.active` value passed in the commandline or `-Dspring.profiles.active` set in `JAVA_OPTS` active: '@spring.profiles.active@' + artemis: + user: ${ACTIVEMQ_ARTEMIS_USER:admin} + password: ${ACTIVEMQ_ARTEMIS_PASSWORD:admin} + broker-url: tcp://${ACTIVEMQ_ARTEMIS_HOST:localhost}:${ACTIVEMQ_ARTEMIS_PORT:61616} + server: port: 8083 @@ -24,7 +29,7 @@ management: probability: 1.0 zipkin: tracing: - endpoint: http://localhost:9411/api/v2/spans + endpoint: http://${ZIPKIN_HOST:localhost}:${ZIPKIN_PORT:9411}/api/v2/spans health: jms: enabled: true diff --git a/config/docker-compose.yml b/docker/docker-compose-dev.yml similarity index 85% rename from config/docker-compose.yml rename to docker/docker-compose-dev.yml index 2e24188..79ae3ee 100644 --- a/config/docker-compose.yml +++ b/docker/docker-compose-dev.yml @@ -1,3 +1,4 @@ +# use this to run dependencies like activemq, email, mysql, keycloak using docker for DEVELOPMENT version: '3' services: activemq_artemis: @@ -12,7 +13,7 @@ services: - 8161:8161 # use this to access from browser - 61616:61616 networks: - - seedappnet + - gtapp-network mysql: image: 'mysql' environment: @@ -22,7 +23,7 @@ services: - 3306:3306 command: mysqld --lower_case_table_names=1 --character_set_server=utf8mb4 --explicit_defaults_for_timestamp networks: - - seedappnet + - gtapp-network emailhog: image: 'richarvey/mailhog' container_name: mailhog @@ -30,14 +31,14 @@ services: - 1025:1025 - 8025:8025 # use this to access from browser networks: - - seedappnet + - gtapp-network zipkin: image: 'openzipkin/zipkin' container_name: zipkin ports: - 9411:9411 networks: - - seedappnet + - gtapp-network keycloak: image: 'quay.io/keycloak/keycloak:25.0.6' container_name: keycloak @@ -53,18 +54,17 @@ services: volumes: - ../main-app/main-webapp/src/main/resources/keycloak/:/opt/keycloak/data/import ports: - - 8082:8080 + - 8080:8080 - 9443:9443 networks: - - seedappnet + - gtapp-network volumes: esdata1: driver: local networks: - seedappnet: + gtapp-network: driver: bridge #run using -#docker-compose -f docker-compose.yml up -# or just docker-compose up +#docker compose -f docker-compose-dev.yml up diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 0000000..cd55080 --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,99 @@ +version: '3' +services: + localhost: #expose all container ports so they can use services using localhost:PORT + image: alpine:latest + command: sleep infinity + ports: + - "8080:8080" + - "8161:8161" + - "3306:3306" + - "1025:1025" + - "8025:8025" + - "9411:9411" + - "8081:8081" + - "8083:8083" + - "8084:8084" + - "8085:8085" + - "8086:8086" + - "8161:8161" + - "61616:61616" + activemq: + # its not supported in M1 Mac, workaround is to enable Rosetta in Docker + # Docker settings → Features in development → check ☑ Use Rosetta for x86/amd64 emulation on Apple Silicon, and then restart Docker. + image: 'apache/activemq-artemis:2.37.0' + environment: + - "ARTEMIS_USER=admin" + - "ARTEMIS_PASSWORD=admin" + network_mode: "service:localhost" + mysql: + image: 'mysql' + environment: + - "MYSQL_USER=seedappuser" + - "MYSQL_ROOT_PASSWORD=password" + - "MYSQL_DATABASE=seedapp" + command: mysqld --lower_case_table_names=1 --character_set_server=utf8mb4 --explicit_defaults_for_timestamp + network_mode: "service:localhost" + emailhog: + image: 'richarvey/mailhog' + network_mode: "service:localhost" + zipkin: + image: 'openzipkin/zipkin' + network_mode: "service:localhost" + keycloak: + image: 'quay.io/keycloak/keycloak:25.0.6' + command: start-dev --import-realm + environment: + - "KEYCLOAK_DB=dev-file" + - "KEYCLOAK_ADMIN=admin" + - "KEYCLOAK_ADMIN_PASSWORD=admin" + - "KEYCLOAK_FEATURES=scripts" + - "KEYCLOAK_HTTP_PORT=8080" + - "KEYCLOAK_HTTPS_PORT=9443" + volumes: + - ../main-app/main-webapp/src/main/resources/keycloak/:/opt/keycloak/data/import + network_mode: "service:localhost" + content-checker-service: + image: gtapp-content-checker-service:latest + environment: + - "ZIPKIN_HOST=zipkin" + network_mode: "service:localhost" + depends_on: + - zipkin + - activemq + email-service: + image: gtapp-email-service:latest + environment: + - "SPRING_PROFILES_ACTIVE=prod" + network_mode: "service:localhost" + depends_on: + - emailhog + - zipkin + trend-service: + image: gtapp-trend-service:latest + environment: + - "SPRING_PROFILES_ACTIVE=prod" + network_mode: "service:localhost" + depends_on: + - zipkin + report-service: + image: gtapp-report-service:latest + environment: + - "SPRING_PROFILES_ACTIVE=prod" + network_mode: "service:localhost" + depends_on: + - zipkin + - mysql + - keycloak + main-webapp: + image: gtapp-main-webapp:latest + environment: + - "SPRING_PROFILES_ACTIVE=prod" + network_mode: "service:localhost" + depends_on: + - zipkin + - email-service + - mysql + - activemq + - keycloak + volumes: + - /var/tmp/:/tmp/uploads/attachments/ diff --git a/email/email-service/pom.xml b/email/email-service/pom.xml index d56dd43..2e674d4 100755 --- a/email/email-service/pom.xml +++ b/email/email-service/pom.xml @@ -111,6 +111,12 @@ org.springframework.boot spring-boot-maven-plugin + + gtapp-${project.name} + + true + + org.springframework.cloud @@ -138,26 +144,4 @@ - - - - dev - - true - - - dev - dev - - - - prod - - prod - prod - - - - - diff --git a/email/email-service/src/main/resources/application-default.yml b/email/email-service/src/main/resources/application-default.yml index 0a6f272..4617b5d 100644 --- a/email/email-service/src/main/resources/application-default.yml +++ b/email/email-service/src/main/resources/application-default.yml @@ -1,3 +1,3 @@ spring: profiles: - active: dev + active: local diff --git a/email/email-service/src/main/resources/application.yml b/email/email-service/src/main/resources/application.yml index 6b31252..326fbac 100755 --- a/email/email-service/src/main/resources/application.yml +++ b/email/email-service/src/main/resources/application.yml @@ -7,7 +7,7 @@ spring: # Either way, it can be overridden by `--spring.profiles.active` value passed in the commandline or `-Dspring.profiles.active` set in `JAVA_OPTS` active: '@spring.profiles.active@' mail: - host: localhost + host: ${MAILHOG_HOST:localhost} port: ${MAILHOG_PORT:1025} username: password: @@ -31,6 +31,6 @@ management: probability: 1.0 zipkin: tracing: - endpoint: http://localhost:9411/api/v2/spans + endpoint: http://${ZIPKIN_HOST:localhost}:${ZIPKIN_PORT:9411}/api/v2/spans diff --git a/email/email-service/src/test/resources/application.yml b/email/email-service/src/test/resources/application.yml index 73251db..a3a91f5 100755 --- a/email/email-service/src/test/resources/application.yml +++ b/email/email-service/src/test/resources/application.yml @@ -16,7 +16,7 @@ spring: oauth2: resourceserver: jwt: - issuer-uri: http://localhost:${KEYCLOAK_PORT:8082}/realms/articleapp + issuer-uri: http://localhost:${KEYCLOAK_PORT:8080}/realms/articleapp logging.level: ROOT: WARN gt: INFO diff --git a/main-app/main-webapp/pom.xml b/main-app/main-webapp/pom.xml index f6f16d5..8c96c9b 100644 --- a/main-app/main-webapp/pom.xml +++ b/main-app/main-webapp/pom.xml @@ -13,8 +13,6 @@ - - ${project.parent.version} @@ -126,6 +124,11 @@ commons-io commons-io + + com.mysql + mysql-connector-j + runtime + @@ -170,11 +173,6 @@ - - org.springdoc - springdoc-openapi-starter-webmvc-ui - - org.webjars webjars-locator-core @@ -237,10 +235,12 @@ com.github.dasniko testcontainers-keycloak + test org.testcontainers testcontainers + test org.testcontainers @@ -251,6 +251,7 @@ org.testcontainers mysql true + test @@ -318,6 +319,12 @@ org.springframework.boot spring-boot-maven-plugin + + gtapp-${project.name} + + true + + @@ -509,67 +516,26 @@ + - tls - - ,tls - - - - dev - - true - + local - org.springframework.boot - spring-boot-devtools + org.springdoc + springdoc-openapi-starter-webmvc-ui + ${springdoc-openapi-ui.version} true - com.mysql - mysql-connector-j - runtime - - - - dev${profile.tls}${profile.withTestContainer} - dev - - - - withTestContainer - - - org.testcontainers - testcontainers - - - com.github.dasniko - testcontainers-keycloak - - - org.testcontainers - mysql - - - - ,withTestContainer - - - - prod - - - com.mysql - mysql-connector-j + org.springframework.boot + spring-boot-devtools - prod - prod + local + local - + diff --git a/main-app/main-webapp/src/main/java/gt/app/DataCreator.java b/main-app/main-webapp/src/main/java/gt/app/DataCreator.java index 089f550..d2c39de 100644 --- a/main-app/main-webapp/src/main/java/gt/app/DataCreator.java +++ b/main-app/main-webapp/src/main/java/gt/app/DataCreator.java @@ -19,7 +19,7 @@ import java.util.stream.Stream; @Component -@Profile({"dev", "test"}) +@Profile({"local", "test"}) @RequiredArgsConstructor @Slf4j public class DataCreator { diff --git a/main-app/main-webapp/src/main/java/gt/app/config/Constants.java b/main-app/main-webapp/src/main/java/gt/app/config/Constants.java index be7b3ec..09e735a 100644 --- a/main-app/main-webapp/src/main/java/gt/app/config/Constants.java +++ b/main-app/main-webapp/src/main/java/gt/app/config/Constants.java @@ -4,7 +4,7 @@ public final class Constants { public static final String ROLE_ADMIN = "ROLE_ADMIN"; public static final String ROLE_USER = "ROLE_USER"; - public static final String SPRING_PROFILE_DEVELOPMENT = "dev"; + public static final String SPRING_PROFILE_DEVELOPMENT = "local"; public static final String SPRING_PROFILE_PRODUCTION = "prod"; public static final String SPRING_PROFILE_DOCKER = "docker"; public static final String SPRING_PROFILE_TEST = "test"; diff --git a/main-app/main-webapp/src/main/java/gt/app/config/DockerContainerConfig.java b/main-app/main-webapp/src/main/java/gt/app/config/DockerContainerConfig.java deleted file mode 100644 index 866f685..0000000 --- a/main-app/main-webapp/src/main/java/gt/app/config/DockerContainerConfig.java +++ /dev/null @@ -1,62 +0,0 @@ -package gt.app.config; - -import dasniko.testcontainers.keycloak.KeycloakContainer; -import lombok.extern.slf4j.Slf4j; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; -import org.testcontainers.containers.GenericContainer; -import org.testcontainers.containers.MySQLContainer; - -import java.util.List; - -import static java.lang.System.setProperty; - -@Profile("withTestContainer") -@Configuration -@Slf4j -class DockerContainerConfig { - - /* - - Started by Docker TestContainer in withTestContainer profile - - ActiveMQ Artemis - - Embedded Apps - started in dev profile - - H2 - - */ - - - static { - log.info("Starting docker containers using TestContainers"); - - String userPwd = "admin";//use same for all - - var mysql = new MySQLContainer<>("mysql").withDatabaseName("seedapp").withUsername(userPwd).withPassword(userPwd); - mysql.start(); - - var activeMQ = new GenericContainer<>("apache/activemq-artemis:2.37.0"); - activeMQ.setEnv(List.of("ARTEMIS_USER=admin", "ARTEMIS_PASSWORD=admin")); - activeMQ.withExposedPorts(61616); - activeMQ.start(); //using default ports - - var kc = new KeycloakContainer("quay.io/keycloak/keycloak:25.0.6").withRealmImportFile("keycloak/realm-export.json"); - kc.start(); - - setProperty("KEYCLOAK_PORT", Integer.toString(kc.getHttpPort())); - - setProperty("ACTIVEMQ_ARTEMIS_HOST", activeMQ.getHost()); - setProperty("ACTIVEMQ_ARTEMIS_PORT", Integer.toString(activeMQ.getMappedPort(61616))); - setProperty("ACTIVEMQ_ARTEMIS_USER", userPwd); - setProperty("ACTIVEMQ_ARTEMIS_PASSWORD", userPwd); - - setProperty("MYSQL_HOST", mysql.getHost()); - setProperty("MYSQL_PORT", Integer.toString(mysql.getMappedPort(3306))); - setProperty("MYSQL_DB", "seedapp"); - setProperty("MYSQL_USERNAME", userPwd); - setProperty("MYSQL_PASSWORD", userPwd); - - log.info("Started docker containers using TestContainers"); - } - -} diff --git a/main-app/main-webapp/src/main/resources/application-default.yml b/main-app/main-webapp/src/main/resources/application-default.yml index 59f2336..503974a 100644 --- a/main-app/main-webapp/src/main/resources/application-default.yml +++ b/main-app/main-webapp/src/main/resources/application-default.yml @@ -1,4 +1,3 @@ spring: profiles: - active: dev # this will use manually started activemq, email and mysql servers using docker-compose -# active: dev,withTestContainer # use this to start activemq, email and mysql servers with DockerContainerConfig + active: local # this will use manually started activemq, email and mysql servers using docker compose diff --git a/main-app/main-webapp/src/main/resources/application-dev.yml b/main-app/main-webapp/src/main/resources/application-dev.yml deleted file mode 100644 index e6d1045..0000000 --- a/main-app/main-webapp/src/main/resources/application-dev.yml +++ /dev/null @@ -1,54 +0,0 @@ -spring: - thymeleaf: - cache: true # set to false, this if you are working on UI - prefix: file:main-app/main-webapp/src/main/resources/templates/ #directly serve from src folder instead of target - web: - resources: - static-locations: - - file:src/main/resources/static/ #directly serve from src folder instead of target - - classpath:/META-INF/resources/ - - classpath:/resources/ - - classpath:/static/ - - classpath:/public/ - cache: - period: 500000 - chain: - cache: true - mvc: - static-path-pattern: /static/** - - datasource: - url: jdbc:mysql://${MYSQL_HOST:localhost}:${MYSQL_PORT:3306}/${MYSQL_DB:seedapp}?useUnicode=true&allowPublicKeyRetrieval=true - username: ${MYSQL_USERNAME:root} - password: ${MYSQL_PASSWORD:password} - jpa: - show-sql: false - hibernate: - ddl-auto: none # we use liquibase - generate_statistics: true - naming: - physical-strategy: gt.app.hibernate.PrefixedNamingStrategy - implicit-strategy: org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy - jooq: - sql-dialect: MySQL - artemis: - user: ${ACTIVEMQ_ARTEMIS_USER:admin} - password: ${ACTIVEMQ_ARTEMIS_PASSWORD:admin} - broker-url: tcp://${ACTIVEMQ_ARTEMIS_HOST:localhost}:${ACTIVEMQ_ARTEMIS_PORT:61616} - liquibase: - enabled: true - -feign-clients: - email-service: - url: http://localhost:8085/ #TODO: use service discovery - report-service: - url: http://localhost:8086/ #TODO: use service discovery - -logging.level: - org.jooq.tools.LoggerListener: DEBUG - org.springframework.security: INFO - org.springframework.security.web: INFO - org.springframework.cloud: INFO -# org.hibernate.SQL: debug -# org.hibernate.type: TRACE - 'org.hibernate.engine.internal.StatisticalLoggingSessionEventListener': info diff --git a/main-app/main-webapp/src/main/resources/application-local.yml b/main-app/main-webapp/src/main/resources/application-local.yml new file mode 100644 index 0000000..c96000a --- /dev/null +++ b/main-app/main-webapp/src/main/resources/application-local.yml @@ -0,0 +1,25 @@ +spring: + thymeleaf: + cache: true # set to false, this if you are working on UI + prefix: file:main-app/main-webapp/src/main/resources/templates/ #directly serve from src folder instead of target + web: + resources: + static-locations: + - file:src/main/resources/static/ #directly serve from src folder instead of target + - classpath:/META-INF/resources/ + - classpath:/resources/ + - classpath:/static/ + - classpath:/public/ + cache: + period: 500000 + chain: + cache: true + +logging.level: + org.jooq.tools.LoggerListener: DEBUG + org.springframework.security: INFO + org.springframework.security.web: INFO + org.springframework.cloud: INFO +# org.hibernate.SQL: debug +# org.hibernate.type: TRACE + 'org.hibernate.engine.internal.StatisticalLoggingSessionEventListener': info diff --git a/main-app/main-webapp/src/main/resources/application.yml b/main-app/main-webapp/src/main/resources/application.yml index bf561f4..cac1c6f 100644 --- a/main-app/main-webapp/src/main/resources/application.yml +++ b/main-app/main-webapp/src/main/resources/application.yml @@ -1,21 +1,35 @@ spring: application: name: Main-APP + mvc: + static-path-pattern: /static/** profiles: # The commented value for `active` can be replaced with valid spring profiles to load. # Otherwise, it will be filled in by maven when building the WAR file # Either way, it can be overridden by `--spring.profiles.active` value passed in the commandline or `-Dspring.profiles.active` set in `JAVA_OPTS` active: '@spring.profiles.active@' - + jooq: + sql-dialect: MySQL liquibase: - enabled: false + enabled: true change-log: classpath:/liquibase/master.xml jpa: open-in-view: false hibernate: + ddl-auto: none # we use liquibase + generate_statistics: true naming: physical-strategy: gt.app.hibernate.PrefixedNamingStrategy implicit-strategy: org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy + datasource: + url: jdbc:mysql://${MYSQL_HOST:localhost}:${MYSQL_PORT:3306}/${MYSQL_DB:seedapp}?useUnicode=true&allowPublicKeyRetrieval=true + username: ${MYSQL_USERNAME:root} + password: ${MYSQL_PASSWORD:password} + + artemis: + user: ${ACTIVEMQ_ARTEMIS_USER:admin} + password: ${ACTIVEMQ_ARTEMIS_PASSWORD:admin} + broker-url: tcp://${ACTIVEMQ_ARTEMIS_HOST:localhost}:${ACTIVEMQ_ARTEMIS_PORT:61616} cloud: openfeign: micrometer: @@ -26,8 +40,8 @@ spring: # we are using authorization code flow (login within keycloak app web ui) provider: oidc: - # use http://localhost:8082/realms/articleapp/.well-known/openid-configuration to get config from keycloak - issuer-uri: http://localhost:${KEYCLOAK_PORT:8082}/realms/seedapp + # use http://localhost:8080/realms/articleapp/.well-known/openid-configuration to get config from keycloak + issuer-uri: http://${KEYCLOAK_HOST:localhost}:${KEYCLOAK_PORT:8080}/realms/seedapp registration: oidc: # authorization-grant-type: refresh_token @@ -49,6 +63,12 @@ logging: # 'org.springframework.web.socket': TRACE +feign-clients: + email-service: + url: http://${EMAIL_SERVICE_HOST:localhost}:${EMAIL_SERVICE_PORT:8085}/ #TODO: use service discovery + report-service: + url: http://${REPORT_SERVICE_HOST:localhost}:${REPORT_SERVICE_PORT:8086}/ #TODO: use service discovery + app-properties: jms: content-checkerrequest-queue: jms-content-checker-requestqueue @@ -73,8 +93,8 @@ decorator: flexy-pool: threshold: connection: - acquire: -1 lease: 0 + acquisition: -1 datasource-proxy: slow-query: threshold: 1 # 1 second is slow @@ -91,7 +111,7 @@ management: probability: 1.0 zipkin: tracing: - endpoint: http://localhost:9411/api/v2/spans + endpoint: http://${ZIPKIN_HOST:localhost}:${ZIPKIN_PORT:9411}/api/v2/spans health: jms: enabled: true diff --git a/main-app/main-webapp/src/test/java/gt/app/frwk/TestContainerConfig.java b/main-app/main-webapp/src/test/java/gt/app/frwk/TestContainerConfig.java index 7a17777..b9a0a92 100644 --- a/main-app/main-webapp/src/test/java/gt/app/frwk/TestContainerConfig.java +++ b/main-app/main-webapp/src/test/java/gt/app/frwk/TestContainerConfig.java @@ -19,7 +19,7 @@ public class TestContainerConfig { - ActiveMQ Artemis - KeyCloak - Embedded Apps - started in dev profile + Embedded Apps - started in local profile - H2 */ diff --git a/main-app/main-webapp/src/test/resources/application.yml b/main-app/main-webapp/src/test/resources/application.yml index 1eaab8a..fcd6e21 100644 --- a/main-app/main-webapp/src/test/resources/application.yml +++ b/main-app/main-webapp/src/test/resources/application.yml @@ -27,7 +27,7 @@ spring: client: provider: oidc: - issuer-uri: http://localhost:${KEYCLOAK_PORT:8082}/realms/seedapp + issuer-uri: http://localhost:${KEYCLOAK_PORT:8080}/realms/seedapp registration: oidc: client-id: seed-app-gateway-client diff --git a/main-app/report-service/pom.xml b/main-app/report-service/pom.xml index 85ce7cd..3cbc24a 100644 --- a/main-app/report-service/pom.xml +++ b/main-app/report-service/pom.xml @@ -84,6 +84,12 @@ org.springframework.boot spring-boot-maven-plugin + + gtapp-${project.name} + + true + + com.github.spotbugs @@ -105,20 +111,18 @@ - dev - - true - - - dev - dev - - - - prod + local + + + org.springdoc + springdoc-openapi-starter-webmvc-ui + ${springdoc-openapi-ui.version} + true + + - prod - prod + local + local diff --git a/main-app/report-service/src/main/resources/application.yml b/main-app/report-service/src/main/resources/application.yml index 06bf903..0cc1a4e 100755 --- a/main-app/report-service/src/main/resources/application.yml +++ b/main-app/report-service/src/main/resources/application.yml @@ -15,7 +15,7 @@ spring: oauth2: resourceserver: jwt: - issuer-uri: http://localhost:${KEYCLOAK_PORT:8082}/realms/seedapp + issuer-uri: http://${KEYCLOAK_HOST:localhost}:${KEYCLOAK_PORT:8080}/realms/seedapp server: port: 8086 @@ -32,4 +32,4 @@ management: probability: 1.0 zipkin: tracing: - endpoint: http://localhost:9411/api/v2/spans + endpoint: http://${ZIPKIN_HOST:localhost}:${ZIPKIN_PORT:9411}/api/v2/spans diff --git a/trend/trend-service/pom.xml b/trend/trend-service/pom.xml index ef5a678..03b920d 100644 --- a/trend/trend-service/pom.xml +++ b/trend/trend-service/pom.xml @@ -70,6 +70,12 @@ org.springframework.boot spring-boot-maven-plugin + + gtapp-${project.name} + + true + + @@ -92,34 +98,18 @@ - dev - - true - - - - com.h2database - h2 - runtime - - - - dev - dev - - - - prod + local - com.h2database - h2 - runtime + org.springdoc + springdoc-openapi-starter-webmvc-ui + ${springdoc-openapi-ui.version} + true - prod - prod + local + local diff --git a/trend/trend-service/src/main/java/gt/trend/TrendServiceApp.java b/trend/trend-service/src/main/java/gt/trend/TrendServiceApp.java index d10d5da..4bb2615 100644 --- a/trend/trend-service/src/main/java/gt/trend/TrendServiceApp.java +++ b/trend/trend-service/src/main/java/gt/trend/TrendServiceApp.java @@ -4,8 +4,12 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; import org.springframework.core.env.Environment; import org.springframework.jms.annotation.JmsListener; +import org.springframework.jms.support.converter.MappingJackson2MessageConverter; +import org.springframework.jms.support.converter.MessageConverter; +import org.springframework.jms.support.converter.MessageType; import java.net.InetAddress; import java.net.UnknownHostException; @@ -45,4 +49,12 @@ void onArticleRead(ArticleSummaryDto msg) { log.info("Received msg for trend calculation {}", msg); } + + @Bean + MessageConverter jacksonJmsMessageConverter() { + var converter = new MappingJackson2MessageConverter(); + converter.setTargetType(MessageType.TEXT); + converter.setTypeIdPropertyName("_type"); + return converter; + } } diff --git a/trend/trend-service/src/main/resources/application-default.yml b/trend/trend-service/src/main/resources/application-default.yml index 0a6f272..4617b5d 100644 --- a/trend/trend-service/src/main/resources/application-default.yml +++ b/trend/trend-service/src/main/resources/application-default.yml @@ -1,3 +1,3 @@ spring: profiles: - active: dev + active: local diff --git a/trend/trend-service/src/main/resources/application-dev.yml b/trend/trend-service/src/main/resources/application-dev.yml deleted file mode 100644 index a6c705b..0000000 --- a/trend/trend-service/src/main/resources/application-dev.yml +++ /dev/null @@ -1,6 +0,0 @@ -spring: - artemis: - host: ${ACTIVEMQ_ARTEMIS_HOST:localhost} - port: ${ACTIVEMQ_ARTEMIS_PORT:61616} - user: admin - password: admin diff --git a/trend/trend-service/src/main/resources/application.yml b/trend/trend-service/src/main/resources/application.yml index 229a716..8c6620f 100644 --- a/trend/trend-service/src/main/resources/application.yml +++ b/trend/trend-service/src/main/resources/application.yml @@ -6,6 +6,10 @@ spring: # Otherwise, it will be filled in by maven when building the WAR file # Either way, it can be overridden by `--spring.profiles.active` value passed in the commandline or `-Dspring.profiles.active` set in `JAVA_OPTS` active: '@spring.profiles.active@' + artemis: + user: ${ACTIVEMQ_ARTEMIS_USER:admin} + password: ${ACTIVEMQ_ARTEMIS_PASSWORD:admin} + broker-url: tcp://${ACTIVEMQ_ARTEMIS_HOST:localhost}:${ACTIVEMQ_ARTEMIS_PORT:61616} server: port: 8084 @@ -22,4 +26,4 @@ management: probability: 1.0 zipkin: tracing: - endpoint: http://localhost:9411/api/v2/spans + endpoint: http://${ZIPKIN_HOST:localhost}:${ZIPKIN_PORT:9411}/api/v2/spans