Skip to content

Commit 40cd728

Browse files
Merge branch 'develop' into develop
2 parents d1cec38 + 6ab7b18 commit 40cd728

31 files changed

Lines changed: 279 additions & 134 deletions

Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# --- Stage 1: Build the application using Maven ---
2+
FROM maven:3.9.6-eclipse-temurin-17 AS build
3+
4+
WORKDIR /app
5+
6+
COPY . .
7+
8+
# Build the application while caching Maven dependencies to speed up future builds
9+
RUN --mount=type=cache,target=/root/.m2 \
10+
mvn clean package -DENV_VAR=docker -DskipTests -Dgit.skip=true
11+
12+
# --- Stage 2: Run the application with a minimal JRE image ---
13+
FROM eclipse-temurin:17-jre
14+
15+
WORKDIR /app
16+
17+
# Copy the built WAR file from the build stage
18+
COPY --from=build /app/target/*.war app.war
19+
20+
EXPOSE 8080
21+
22+
# Run the application
23+
ENTRYPOINT ["java", "-jar", "app.war"]

pom.xml

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,17 @@
3535
<version>3.2.2</version>
3636
</dependency>
3737

38+
<dependency>
39+
<groupId>org.springframework.boot</groupId>
40+
<artifactId>spring-boot-starter</artifactId>
41+
<exclusions>
42+
<exclusion>
43+
<groupId>org.springframework.boot</groupId>
44+
<artifactId>spring-boot-starter-logging</artifactId>
45+
</exclusion>
46+
</exclusions>
47+
</dependency>
48+
3849
<dependency>
3950
<groupId>co.elastic.logging</groupId>
4051
<artifactId>logback-ecs-encoder</artifactId>
@@ -43,16 +54,6 @@
4354

4455
<!--<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-log4j2</artifactId>
4556
<version>3.2.2</version> </dependency> -->
46-
<dependency>
47-
<groupId>org.slf4j</groupId>
48-
<artifactId>slf4j-api</artifactId>
49-
<version>2.1.0-alpha1</version>
50-
</dependency>
51-
<dependency>
52-
<groupId>org.slf4j</groupId>
53-
<artifactId>slf4j-simple</artifactId>
54-
<version>2.1.0-alpha1</version>
55-
</dependency>
5657
<!-- Swagger -->
5758
<dependency>
5859
<groupId>org.springdoc</groupId>
@@ -413,6 +414,18 @@
413414
</execution>
414415
</executions>
415416
</plugin>
417+
<plugin>
418+
<groupId>org.springframework.boot</groupId>
419+
<artifactId>spring-boot-maven-plugin</artifactId>
420+
<version>3.2.2</version>
421+
<executions>
422+
<execution>
423+
<goals>
424+
<goal>repackage</goal>
425+
</goals>
426+
</execution>
427+
</executions>
428+
</plugin>
416429
</plugins>
417430
</build>
418431
<reporting>

src/main/environment/ecd_ci.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,7 @@ logging.file.name=@env.ECD_API_LOGGING_FILE_NAME@
2929
springdoc.api-docs.enabled=@env.SWAGGER_DOC_ENABLED@
3030
springdoc.swagger-ui.enabled=@env.SWAGGER_DOC_ENABLED@
3131

32+
spring.redis.host=@env.REDIS_HOST@
33+
34+
cors.allowed-origins=@env.CORS_ALLOWED_ORIGINS@
35+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# DB Connections
2+
spring.datasource.url=${DATABASE_URL}
3+
spring.datasource.username=${DATABASE_USERNAME}
4+
spring.datasource.password=${DATABASE_PASSWORD}
5+
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
6+
7+
# Secondary DB
8+
secondary.datasource.username=${REPORTING_DATABASE_USERNAME}
9+
secondary.datasource.password=${REPORTING_DATABASE_PASSWORD}
10+
secondary.datasource.url=${REPORTING_DATABASE_URL}
11+
secondary.datasource.driver-class-name=com.mysql.jdbc.Driver
12+
13+
# API URLs
14+
registerBeneficiaryUrl=${COMMON_API}/beneficiary/create
15+
beneficiaryEditUrl=${COMMON_API}/beneficiary/update
16+
17+
# JWT Configuration
18+
jwt.secret=${JWT_SECRET_KEY}
19+
20+
# ELK Logging
21+
logging.path=logs/
22+
logging.file.name=${ECD_API_LOGGING_FILE_NAME}
23+
24+
# Swagger Documentation
25+
springdoc.api-docs.enabled=${SWAGGER_DOC_ENABLED}
26+
springdoc.swagger-ui.enabled=${SWAGGER_DOC_ENABLED}
27+
28+
spring.redis.host=${REDIS_HOST}

src/main/environment/ecd_example.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,6 @@ springdoc.swagger-ui.enabled=true
2323
jwt.secret=my-32-character-ultra-secure-and-ultra-long-secret
2424
#If both properties are set, only logging.file.name takes effect.
2525
logging.path=logs/
26-
logging.file.name=logs/ecd-api.log
26+
logging.file.name=logs/ecd-api.log
27+
28+
cors.allowed-origins=http://localhost:*

src/main/java/com/iemr/ecd/config/WebConfiguration.java

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,33 @@
2424
import org.springframework.context.annotation.Configuration;
2525
import org.springframework.web.servlet.config.annotation.CorsRegistry;
2626
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
27+
import java.util.Arrays;
28+
import org.springframework.beans.factory.annotation.Value;
29+
import org.slf4j.Logger;
30+
import org.slf4j.LoggerFactory;
2731

2832
@Configuration
2933
public class WebConfiguration implements WebMvcConfigurer {
3034

35+
private static final Logger logger = LoggerFactory.getLogger(WebConfiguration.class);
36+
37+
@Value("${cors.allowed-origins}")
38+
private String allowedOrigins;
39+
3140
@Override
3241
public void addCorsMappings(CorsRegistry registry) {
33-
registry.addMapping("/**").allowedMethods("*");
34-
}
42+
String[] originPatterns = Arrays.stream(allowedOrigins.split(","))
43+
.map(String::trim)
44+
.toArray(String[]::new);
3545

46+
logger.info("Initializing CORS configuration with allowed origins: {}", Arrays.toString(originPatterns));
47+
48+
registry.addMapping("/**")
49+
.allowedOriginPatterns(originPatterns)
50+
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
51+
.allowedHeaders("*")
52+
.exposedHeaders("Authorization", "Jwttoken")
53+
.allowCredentials(true)
54+
.maxAge(3600);
55+
}
3656
}

src/main/java/com/iemr/ecd/controller/associate/AutoPreviewDialingController.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import org.springframework.http.HttpStatus;
2828
import org.springframework.http.MediaType;
2929
import org.springframework.http.ResponseEntity;
30-
import org.springframework.web.bind.annotation.CrossOrigin;
30+
3131
import org.springframework.web.bind.annotation.GetMapping;
3232
import org.springframework.web.bind.annotation.PathVariable;
3333
import org.springframework.web.bind.annotation.PostMapping;
@@ -47,7 +47,6 @@
4747

4848
@RestController
4949
@RequestMapping(value = "/autoPreviewDialing", headers = "Authorization")
50-
@CrossOrigin()
5150
public class AutoPreviewDialingController {
5251

5352
@Autowired

src/main/java/com/iemr/ecd/controller/associate/BeneficiaryCallHistoryController.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import org.springframework.http.HttpStatus;
2626
import org.springframework.http.MediaType;
2727
import org.springframework.http.ResponseEntity;
28-
import org.springframework.web.bind.annotation.CrossOrigin;
28+
2929
import org.springframework.web.bind.annotation.GetMapping;
3030
import org.springframework.web.bind.annotation.PathVariable;
3131
import org.springframework.web.bind.annotation.PostMapping;
@@ -46,7 +46,6 @@
4646

4747
@RestController
4848
@RequestMapping(value = "/callHistory", headers = "Authorization")
49-
@CrossOrigin()
5049
public class BeneficiaryCallHistoryController {
5150
@Autowired
5251
private BeneficiaryCallHistoryImpl beneficiaryCallHistoryImpl;

src/main/java/com/iemr/ecd/controller/associate/BeneficiaryRegistrationController.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import org.springframework.http.HttpStatus;
2626
import org.springframework.http.MediaType;
2727
import org.springframework.http.ResponseEntity;
28-
import org.springframework.web.bind.annotation.CrossOrigin;
28+
2929
import org.springframework.web.bind.annotation.PostMapping;
3030
import org.springframework.web.bind.annotation.RequestBody;
3131
import org.springframework.web.bind.annotation.RequestHeader;
@@ -43,14 +43,12 @@
4343

4444
@RestController
4545
@RequestMapping(value = "/beneficary", headers = "Authorization")
46-
@CrossOrigin()
4746

4847
public class BeneficiaryRegistrationController {
4948

5049
@Autowired
5150
private BeneficiaryRegistrationServiceImpl beneficiaryRegistrationServiceImpl;
5251

53-
@CrossOrigin()
5452
@PostMapping(value = "/registration", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
5553
@Operation(summary = "Create beneficiary registration", description = "Desc - Create Beneficiary registration")
5654
@ApiResponses(value = {
@@ -67,7 +65,6 @@ public ResponseEntity<Object> beneficiaryRegistration(@RequestBody RequestBenefi
6765
HttpStatus.OK);
6866
}
6967

70-
@CrossOrigin()
7168
@PostMapping(value = "/updateBeneficiaryDetails", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
7269
@Operation(summary = "Update beneficiary details", description = "Desc - Update Beneficiary details")
7370
@ApiResponses(value = {

src/main/java/com/iemr/ecd/controller/associate/CallClosureController.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import org.springframework.http.HttpStatus;
2626
import org.springframework.http.MediaType;
2727
import org.springframework.http.ResponseEntity;
28-
import org.springframework.web.bind.annotation.CrossOrigin;
28+
2929
import org.springframework.web.bind.annotation.PostMapping;
3030
import org.springframework.web.bind.annotation.RequestBody;
3131
import org.springframework.web.bind.annotation.RequestMapping;
@@ -42,12 +42,10 @@
4242

4343
@RestController
4444
@RequestMapping(value = "/closure", headers = "Authorization")
45-
@CrossOrigin()
4645
public class CallClosureController {
4746
@Autowired
4847
private CallClosureImpl callClosureImpl;
4948

50-
@CrossOrigin()
5149
@PostMapping(value = "/closeCall", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
5250
@Operation(summary = "Call closure", description = "Desc - Call closure")
5351
@ApiResponses(value = {

0 commit comments

Comments
 (0)