diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5ff301f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +# --- 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=docker -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 + +# Run the application +ENTRYPOINT ["java", "-jar", "app.war"] diff --git a/pom.xml b/pom.xml index 186ddfe..b97d35f 100644 --- a/pom.xml +++ b/pom.xml @@ -35,6 +35,17 @@ 3.2.2 + + org.springframework.boot + spring-boot-starter + + + org.springframework.boot + spring-boot-starter-logging + + + + co.elastic.logging logback-ecs-encoder @@ -43,16 +54,6 @@ - - org.slf4j - slf4j-api - 2.1.0-alpha1 - - - org.slf4j - slf4j-simple - 2.1.0-alpha1 - org.springdoc @@ -409,6 +410,18 @@ + + org.springframework.boot + spring-boot-maven-plugin + 3.2.2 + + + + repackage + + + + diff --git a/src/main/environment/ecd_ci.properties b/src/main/environment/ecd_ci.properties index 66a1f13..95d8bcb 100644 --- a/src/main/environment/ecd_ci.properties +++ b/src/main/environment/ecd_ci.properties @@ -29,3 +29,4 @@ logging.file.name=@env.ECD_API_LOGGING_FILE_NAME@ springdoc.api-docs.enabled=@env.SWAGGER_DOC_ENABLED@ springdoc.swagger-ui.enabled=@env.SWAGGER_DOC_ENABLED@ +spring.redis.host=@env.REDIS_HOST@ \ No newline at end of file diff --git a/src/main/environment/ecd_docker.properties b/src/main/environment/ecd_docker.properties new file mode 100644 index 0000000..6f7d879 --- /dev/null +++ b/src/main/environment/ecd_docker.properties @@ -0,0 +1,28 @@ +# 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 + +# Secondary DB +secondary.datasource.username=${REPORTING_DATABASE_USERNAME} +secondary.datasource.password=${REPORTING_DATABASE_PASSWORD} +secondary.datasource.url=${REPORTING_DATABASE_URL} +secondary.datasource.driver-class-name=com.mysql.jdbc.Driver + +# API URLs +registerBeneficiaryUrl=${COMMON_API}/beneficiary/create +beneficiaryEditUrl=${COMMON_API}/beneficiary/update + +# JWT Configuration +jwt.secret=${JWT_SECRET_KEY} + +# ELK Logging +logging.path=logs/ +logging.file.name=${ECD_API_LOGGING_FILE_NAME} + +# Swagger Documentation +springdoc.api-docs.enabled=${SWAGGER_DOC_ENABLED} +springdoc.swagger-ui.enabled=${SWAGGER_DOC_ENABLED} + +spring.redis.host=${REDIS_HOST} \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 64ee941..4505657 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -41,7 +41,6 @@ spring.http.multipart.max-file-size=10MB spring.jackson.serialization.fail-on-empty-beans=false spring.session.store-type=redis -spring.redis.host=localhost spring.redis.port=6379 iemr.session.expiry.time.sec=7200