1- FROM eclipse-temurin:21-jdk
1+
2+ # Build stage
3+ FROM eclipse-temurin:21-jdk AS build
24
35WORKDIR /app
46
@@ -14,18 +16,27 @@ COPY settings.gradle .
1416# Make the gradlew script executable
1517RUN chmod +x ./gradlew
1618
17- # Configure Gradle to use the daemon
18- ENV GRADLE_OPTS="-Dorg.gradle.daemon=true -Dorg.gradle.configureondemand=true -Dorg.gradle.parallel=true"
19+ # Copy the source code
20+ COPY src src
21+
22+ # Build the application
23+ RUN ./gradlew build --no-daemon -x test
24+
25+ # Runtime stage
26+ FROM eclipse-temurin:21-jre
27+
28+ WORKDIR /app
1929
20- # Environment variables for Spring Boot DevTools
21- ENV SPRING_DEVTOOLS_RESTART_ENABLED=true
22- ENV SPRING_DEVTOOLS_LIVERELOAD_ENABLED=true
30+ # Copy the built application from the build stage
31+ COPY --from=build /app/build/libs/*.jar app.jar
2332
24- # Disable Docker Compose support in Spring Boot
33+ # Environment variables for Spring Boot
34+ ENV SPRING_DEVTOOLS_RESTART_ENABLED=false
35+ ENV SPRING_DEVTOOLS_LIVERELOAD_ENABLED=false
2536ENV SPRING_DOCKER_COMPOSE_ENABLED=false
2637
2738# Expose the port the app runs on
2839EXPOSE 8080
2940
30- # Command to run the application with development options
31- CMD ["./gradlew " , "bootRun" , "--no-daemon " , "-Dspring-boot.run.jvmArguments='-Dspring.devtools.restart.enabled=true -Dspring.devtools.livereload.enabled=true' " ]
41+ # Command to run the application
42+ CMD ["java " , "-jar " , "app.jar " ]
0 commit comments