FROM gradle:latest AS cache RUN mkdir -p /home/gradle/cache_home ENV GRADLE_USER_HOME=/home/gradle/cache_home COPY build.gradle.kts gradle.properties settings.gradle.kts /home/gradle/app/ COPY gradle /home/gradle/app/gradle WORKDIR /home/gradle/app RUN gradle dependencies --no-daemon FROM gradle:latest AS build COPY --from=cache /home/gradle/cache_home /home/gradle/.gradle COPY . /usr/src/app/ WORKDIR /usr/src/app RUN ./gradlew build -x test FROM amazoncorretto:22 AS runtime EXPOSE 8080 RUN mkdir /app COPY --from=build /usr/src/app/build/libs/*.jar /app/ktor-app.jar ENTRYPOINT ["java", "-jar", "/app/ktor-app.jar"]