From 18453be6390ee026ecd1b5fd6d545a82eb6fd9c8 Mon Sep 17 00:00:00 2001 From: Suraj Date: Fri, 9 May 2025 16:16:13 +0530 Subject: [PATCH 1/3] feat: add Dockerfile and update pom.xml plugin for repackage --- Dockerfile | 22 ++++++++++++++++++++++ pom.xml | 12 ++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..29e04fd5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +# --- Stage 1: Build the application using Maven --- +FROM maven:3.9.6-eclipse-temurin-17 AS build + +WORKDIR /app + +COPY . . + +# Build the application while caching Maven dependencies to speed up future builds +RUN --mount=type=cache,target=/root/.m2 \ + mvn clean package -DENV_VAR=ci -DskipTests -Dgit.skip=true + +# --- Stage 2: Run the application with a minimal JRE image --- +FROM eclipse-temurin:17-jre + +WORKDIR /app + +# Copy the built WAR file from the build stage +COPY --from=build /app/target/*.war app.war + +EXPOSE 8080 + +ENTRYPOINT ["java", "-jar", "app.war"] diff --git a/pom.xml b/pom.xml index d477f2fe..0947f84b 100644 --- a/pom.xml +++ b/pom.xml @@ -477,6 +477,18 @@ + + org.springframework.boot + spring-boot-maven-plugin + 3.2.2 + + + + repackage + + + + From 839e6b368a735f9ee9c9ca2e3570166169dc10e1 Mon Sep 17 00:00:00 2001 From: Suraj Date: Tue, 27 May 2025 17:41:27 +0530 Subject: [PATCH 2/3] chore: update Dockerfile, pom.xml and CI properties; add docker properties file --- Dockerfile | 2 +- pom.xml | 21 +++-- src/main/environment/common_ci.properties | 1 - src/main/environment/common_docker.properties | 76 +++++++++++++++++++ src/main/resources/logback-spring.xml | 2 +- 5 files changed, 88 insertions(+), 14 deletions(-) create mode 100644 src/main/environment/common_docker.properties diff --git a/Dockerfile b/Dockerfile index 29e04fd5..f99697fa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ COPY . . # Build the application while caching Maven dependencies to speed up future builds RUN --mount=type=cache,target=/root/.m2 \ - mvn clean package -DENV_VAR=ci -DskipTests -Dgit.skip=true + mvn clean package -DENV_VAR=docker -DskipTests -Dgit.skip=true # --- Stage 2: Run the application with a minimal JRE image --- FROM eclipse-temurin:17-jre diff --git a/pom.xml b/pom.xml index 0947f84b..ecd14780 100644 --- a/pom.xml +++ b/pom.xml @@ -56,22 +56,21 @@ org.springframework.boot spring-boot-starter-aop + + org.springframework.boot + spring-boot-starter + + + org.springframework.boot + spring-boot-starter-logging + + + co.elastic.logging logback-ecs-encoder 1.3.2 - - - org.slf4j - slf4j-api - ${slf4j.version} - - - org.slf4j - slf4j-simple - ${slf4j.version} - org.springdoc diff --git a/src/main/environment/common_ci.properties b/src/main/environment/common_ci.properties index 93a55126..f9c2d8de 100644 --- a/src/main/environment/common_ci.properties +++ b/src/main/environment/common_ci.properties @@ -75,4 +75,3 @@ logging.file.name=@env.TM_API_LOGGING_FILE_NAME@ springdoc.api-docs.enabled=@env.SWAGGER_DOC_ENABLED@ springdoc.swagger-ui.enabled=@env.SWAGGER_DOC_ENABLED@ - diff --git a/src/main/environment/common_docker.properties b/src/main/environment/common_docker.properties new file mode 100644 index 00000000..ea943684 --- /dev/null +++ b/src/main/environment/common_docker.properties @@ -0,0 +1,76 @@ + # local env +# DB Connections +spring.datasource.url=${DATABASE_URL} +spring.datasource.username=${DATABASE_USERNAME} +spring.datasource.password=${DATABASE_PASSWORD} +spring.datasource.driver-class-name=com.mysql.jdbc.Driver + +## Carestream URLs +carestreamOrderCreateURL=${COMMON_API}/carestream/createOrder + +## Identity - Common URLs +# Registration +registrationUrl=${COMMON_API}/beneficiary/create + +registrarQuickSearchByIdUrl=${COMMON_API}/beneficiary/searchUserByID + +registrarQuickSearchByPhoneNoUrl=${COMMON_API}/beneficiary/searchUserByPhone + +getBenImageFromIdentity=${IDENTITY_API}/id/benImageByBenRegID + +## beneficiary edit +beneficiaryEditUrl=${COMMON_API}/beneficiary/update + +## Advance Search +registrarAdvanceSearchUrl=${COMMON_API}/beneficiary/searchBeneficiary + +## Data Sync API +dataSyncUploadUrl=${MMU_API}/dataSync/van-to-server + +## Data download API +dataSyncDownloadUrl=${MMU_API}/dataSync/server-to-van + +## TC specialist slot booking +tcSpecialistSlotBook=${SCHEDULER_API}/schedule/bookSlot + +## TC specialist slot cancelling +tcSpecialistSlotCancel=${SCHEDULER_API}/schedule/cancelBookedSlot + +## TM sms to beneficiary(schedule, cancel, reschedule) +sendSMSUrl=${COMMON_API}/sms/sendSMS + +### get openkm doc download url +openkmDocUrl=${COMMON_API}/kmfilemanager/getKMFileDownloadURL + +## Fetosense Url +fetosense-api-url-ANCTestDetails=https://asia-south1-amrit-fetosense.cloudfunctions.net/insertMother + +## apiKey for calling fetosense api +fetosenseAPIKey=${FETOSENSE_API_KEY} + +## TM SMS template details(SMS type) +schedule=TC Schedule SMS +cancel=TC Cancel SMS +reSchedule=TC Reschedule SMS + +snomedCTPageSize=10 +prescription=TMPrescription SMS + +nurseWL=7 +nurseTCWL=7 +docWL=7 +pharmaWL=7 +labWL=7 +radioWL=7 +oncoWL=7 +tcSpeclistWL=7 + +### Redis IP +spring.redis.host=localhost +jwt.secret=${JWT_SECRET_KEY} + +#ELK logging file name +logging.file.name=${TM_API_LOGGING_FILE_NAME} + +springdoc.api-docs.enabled=${SWAGGER_DOC_ENABLED} +springdoc.swagger-ui.enabled=${SWAGGER_DOC_ENABLED} diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml index 50aecbc8..af1e0109 100644 --- a/src/main/resources/logback-spring.xml +++ b/src/main/resources/logback-spring.xml @@ -1,6 +1,6 @@ + value="${LOG_FILE:-${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}}/tm-api}" /> From fe9e4b1c69bba64c61e8fa632d6fdd9497e5cba2 Mon Sep 17 00:00:00 2001 From: Mithun James <1007084+drtechie@users.noreply.github.com> Date: Tue, 17 Jun 2025 12:31:17 +0530 Subject: [PATCH 3/3] fix: add missing TM and FHIR APIS --- src/main/environment/common_ci.properties | 2 +- src/main/environment/common_docker.properties | 2 +- .../com/iemr/tm/utils/JwtAuthenticationUtil.java | 12 +++++++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/environment/common_ci.properties b/src/main/environment/common_ci.properties index b4e8c844..1f9ad128 100644 --- a/src/main/environment/common_ci.properties +++ b/src/main/environment/common_ci.properties @@ -66,7 +66,7 @@ oncoWL=7 tcSpeclistWL=7 ### Redis IP -spring.redis.host=localhost +spring.redis.host=@env.REDIS_HOST@ jwt.secret=@env.JWT_SECRET_KEY@ diff --git a/src/main/environment/common_docker.properties b/src/main/environment/common_docker.properties index ea943684..6316cb8f 100644 --- a/src/main/environment/common_docker.properties +++ b/src/main/environment/common_docker.properties @@ -66,7 +66,7 @@ oncoWL=7 tcSpeclistWL=7 ### Redis IP -spring.redis.host=localhost +spring.redis.host=${REDIS_HOST} jwt.secret=${JWT_SECRET_KEY} #ELK logging file name diff --git a/src/main/java/com/iemr/tm/utils/JwtAuthenticationUtil.java b/src/main/java/com/iemr/tm/utils/JwtAuthenticationUtil.java index 0a59bba6..cd32bea1 100644 --- a/src/main/java/com/iemr/tm/utils/JwtAuthenticationUtil.java +++ b/src/main/java/com/iemr/tm/utils/JwtAuthenticationUtil.java @@ -112,16 +112,22 @@ private Users fetchUserFromDB(String userId) { Users user = userLoginRepo.getUserByUserID(Long.parseLong(userId)); if (user != null) { - // Cache the user in Redis for future requests (cache for 30 minutes) - redisTemplate.opsForValue().set(redisKey, user, 30, TimeUnit.MINUTES); + Users userHash = new Users(); + userHash.setUserID(user.getUserID()); + userHash.setUserName(user.getUserName()); + + // Cache the minimal user in Redis for future requests (cache for 30 minutes) + redisTemplate.opsForValue().set(redisKey, userHash, 30, TimeUnit.MINUTES); // Log that the user has been stored in Redis logger.info("User stored in Redis with key: " + redisKey); + + return user; } else { logger.warn("User not found for userId: " + userId); } - return user; + return null; } }