diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f99697f --- /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=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 + +ENTRYPOINT ["java", "-jar", "app.war"] diff --git a/pom.xml b/pom.xml index ac63bb8..050c2aa 100644 --- a/pom.xml +++ b/pom.xml @@ -392,6 +392,18 @@ + + org.springframework.boot + spring-boot-maven-plugin + 3.2.2 + + + + repackage + + + + diff --git a/src/main/environment/common_ci.properties b/src/main/environment/common_ci.properties index f0ed942..9c52794 100644 --- a/src/main/environment/common_ci.properties +++ b/src/main/environment/common_ci.properties @@ -15,7 +15,7 @@ callcentre-server-ip=@env.CALLCENTRE_SERVER_IP@ common-url=@env.COMMON_API@ ### Redis IP -spring.redis.host=localhost +spring.redis.host=@env.REDIS_HOST@ jwt.secret=@env.JWT_SECRET_KEY@ #ELK logging file name @@ -25,4 +25,3 @@ logging.file.name=@env.SCHEDULER_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 0000000..2a14eb1 --- /dev/null +++ b/src/main/environment/common_docker.properties @@ -0,0 +1,24 @@ +# 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.cj.jdbc.Driver + +spring.jpa.show-sql=true + +spring.profiles.active=test + +callcentre-server-ip=${CALLCENTRE_SERVER_IP} + +common-url=${COMMON_API} + +### Redis IP +spring.redis.host=${REDIS_HOST} +jwt.secret=${JWT_SECRET_KEY} + +#ELK logging file name +logging.file.name=${SCHEDULER_API_LOGGING_FILE_NAME} + +springdoc.api-docs.enabled=${SWAGGER_DOC_ENABLED} +springdoc.swagger-ui.enabled=${SWAGGER_DOC_ENABLED}