diff --git a/functional-tests/src/test/groovy/io/micronaut/gradle/aot/MicronautAOTDockerSpec.groovy b/functional-tests/src/test/groovy/io/micronaut/gradle/aot/MicronautAOTDockerSpec.groovy index 8ec8836e..0c064cce 100644 --- a/functional-tests/src/test/groovy/io/micronaut/gradle/aot/MicronautAOTDockerSpec.groovy +++ b/functional-tests/src/test/groovy/io/micronaut/gradle/aot/MicronautAOTDockerSpec.groovy @@ -1,6 +1,5 @@ package io.micronaut.gradle.aot -import io.micronaut.gradle.AbstractGradleBuildSpec import io.micronaut.gradle.DefaultVersions import org.gradle.testkit.runner.TaskOutcome import spock.lang.IgnoreIf @@ -55,7 +54,7 @@ ENTRYPOINT ["java", "-jar", "/home/app/application.jar"] } - @Requires({ AbstractGradleBuildSpec.graalVmAvailable && !os.windows }) + @Requires({ graalVmAvailable && !os.windows }) def "generates a native optimized docker image"() { withSample("aot/basic-app") @@ -63,25 +62,44 @@ ENTRYPOINT ["java", "-jar", "/home/app/application.jar"] build "optimizedDockerfileNative" def dockerFile = normalizeLineEndings(file("build/docker/native-optimized/DockerfileNative").text) dockerFile = dockerFile.replaceAll("[0-9]\\.[0-9]+\\.[0-9]+", "4.0.0") + .trim() then: - dockerFile == """FROM ghcr.io/graalvm/native-image-community:17-ol${DefaultVersions.ORACLELINUX} AS graalvm -WORKDIR /home/app -COPY --link layers/libs /home/app/libs -COPY --link layers/app /home/app/ -RUN mkdir /home/app/config-dirs -RUN mkdir -p /home/app/config-dirs/generateResourcesConfigFile -RUN mkdir -p /home/app/config-dirs/io.netty/netty-common/4.0.0.Final -RUN mkdir -p /home/app/config-dirs/ch.qos.logback/logback-classic/4.0.0 -COPY --link config-dirs/generateResourcesConfigFile /home/app/config-dirs/generateResourcesConfigFile -COPY --link config-dirs/io.netty/netty-common/4.0.0.Final /home/app/config-dirs/io.netty/netty-common/4.0.0.Final -COPY --link config-dirs/ch.qos.logback/logback-classic/4.0.0 /home/app/config-dirs/ch.qos.logback/logback-classic/4.0.0 -RUN native-image --exclude-config .*/libs/netty-transport-4.0.0.Final.jar ^/META-INF/native-image/.* --exclude-config .*/libs/netty-buffer-4.0.0.Final.jar ^/META-INF/native-image/.* --exclude-config .*/libs/netty-codec-http-4.0.0.Final.jar ^/META-INF/native-image/.* --exclude-config .*/libs/netty-handler-4.0.0.Final.jar ^/META-INF/native-image/.* --exclude-config .*/libs/netty-common-4.0.0.Final.jar ^/META-INF/native-image/.* --exclude-config .*/libs/netty-codec-http2-4.0.0.Final.jar ^/META-INF/native-image/.* -cp /home/app/libs/*.jar:/home/app/resources:/home/app/application.jar --no-fallback -o application -H:ConfigurationFileDirectories=/home/app/config-dirs/generateResourcesConfigFile,/home/app/config-dirs/io.netty/netty-buffer/4.0.0.Final,/home/app/config-dirs/io.netty/netty-common/4.0.0.Final,/home/app/config-dirs/io.netty/netty-codec-http/4.0.0.Final,/home/app/config-dirs/io.netty/netty-transport/4.0.0.Final,/home/app/config-dirs/io.netty/netty-handler/4.0.0.Final,/home/app/config-dirs/io.netty/netty-codec-http2/4.0.0.Final,/home/app/config-dirs/ch.qos.logback/logback-classic/4.0.0 demo.app.Application -FROM cgr.dev/chainguard/wolfi-base:latest -EXPOSE 8080 -COPY --link --from=graalvm /home/app/application /app/application -ENTRYPOINT ["/app/application"] -""" + System.out.println("!!! HAVE:\n\n${dockerFile}") + System.out.println("!!! MUST BE:\n\n" +""" + FROM ghcr.io/graalvm/native-image-community:17-ol${DefaultVersions.ORACLELINUX} AS graalvm + WORKDIR /home/app + COPY --link layers/libs /home/app/libs + COPY --link layers/app /home/app/ + RUN mkdir /home/app/config-dirs + RUN mkdir -p /home/app/config-dirs/generateResourcesConfigFile + RUN mkdir -p /home/app/config-dirs/io.netty/netty-common/4.0.0.Final + RUN mkdir -p /home/app/config-dirs/ch.qos.logback/logback-classic/4.0.0 + COPY --link config-dirs/generateResourcesConfigFile /home/app/config-dirs/generateResourcesConfigFile + COPY --link config-dirs/io.netty/netty-common/4.0.0.Final /home/app/config-dirs/io.netty/netty-common/4.0.0.Final + COPY --link config-dirs/ch.qos.logback/logback-classic/4.0.0 /home/app/config-dirs/ch.qos.logback/logback-classic/4.0.0 + RUN native-image --exclude-config .*/libs/netty-transport-4.0.0.Final.jar ^/META-INF/native-image/.* --exclude-config .*/libs/netty-buffer-4.0.0.Final.jar ^/META-INF/native-image/.* --exclude-config .*/libs/netty-codec-http-4.0.0.Final.jar ^/META-INF/native-image/.* --exclude-config .*/libs/netty-handler-4.0.0.Final.jar ^/META-INF/native-image/.* --exclude-config .*/libs/netty-common-4.0.0.Final.jar ^/META-INF/native-image/.* --exclude-config .*/libs/netty-codec-http2-4.0.0.Final.jar ^/META-INF/native-image/.* -cp /home/app/libs/*.jar:/home/app/resources:/home/app/application.jar --no-fallback -o application -H:ConfigurationFileDirectories=/home/app/config-dirs/generateResourcesConfigFile,/home/app/config-dirs/io.netty/netty-buffer/4.0.0.Final,/home/app/config-dirs/io.netty/netty-common/4.0.0.Final,/home/app/config-dirs/io.netty/netty-codec-http/4.0.0.Final,/home/app/config-dirs/io.netty/netty-transport/4.0.0.Final,/home/app/config-dirs/io.netty/netty-handler/4.0.0.Final,/home/app/config-dirs/io.netty/netty-codec-http2/4.0.0.Final,/home/app/config-dirs/ch.qos.logback/logback-classic/4.0.0 demo.app.Application + FROM cgr.dev/chainguard/wolfi-base:latest + EXPOSE 8080 + COPY --link --from=graalvm /home/app/application /app/application + ENTRYPOINT ["/app/application"]""".stripIndent().trim()) + dockerFile == """ + FROM ghcr.io/graalvm/native-image-community:17-ol${DefaultVersions.ORACLELINUX} AS graalvm + WORKDIR /home/app + COPY --link layers/libs /home/app/libs + COPY --link layers/app /home/app/ + RUN mkdir /home/app/config-dirs + RUN mkdir -p /home/app/config-dirs/generateResourcesConfigFile + RUN mkdir -p /home/app/config-dirs/io.netty/netty-common/4.0.0.Final + RUN mkdir -p /home/app/config-dirs/ch.qos.logback/logback-classic/4.0.0 + COPY --link config-dirs/generateResourcesConfigFile /home/app/config-dirs/generateResourcesConfigFile + COPY --link config-dirs/io.netty/netty-common/4.0.0.Final /home/app/config-dirs/io.netty/netty-common/4.0.0.Final + COPY --link config-dirs/ch.qos.logback/logback-classic/4.0.0 /home/app/config-dirs/ch.qos.logback/logback-classic/4.0.0 + RUN native-image --exclude-config .*/libs/netty-transport-4.0.0.Final.jar ^/META-INF/native-image/.* --exclude-config .*/libs/netty-common-4.0.0.Final.jar ^/META-INF/native-image/.* --exclude-config .*/libs/netty-codec-http2-4.0.0.Final.jar ^/META-INF/native-image/.* --exclude-config .*/libs/netty-buffer-4.0.0.Final.jar ^/META-INF/native-image/.* --exclude-config .*/libs/netty-codec-http-4.0.0.Final.jar ^/META-INF/native-image/.* --exclude-config .*/libs/netty-handler-4.0.0.Final.jar ^/META-INF/native-image/.* -cp /home/alternate/libs/*.jar:/home/alternate/resources:/home/alternate/application.jar --no-fallback -o application -H:ConfigurationFileDirectories=/home/alternate/config-dirs/generateResourcesConfigFile,/home/alternate/config-dirs/io.netty/netty-buffer/4.0.0.Final,/home/alternate/config-dirs/io.netty/netty-common/4.0.0.Final,/home/alternate/config-dirs/io.netty/netty-codec-http/4.0.0.Final,/home/alternate/config-dirs/io.netty/netty-transport/4.0.0.Final,/home/alternate/config-dirs/io.netty/netty-handler/4.0.0.Final,/home/alternate/config-dirs/io.netty/netty-codec-http2/4.0.0.Final example.Application + FROM cgr.dev/chainguard/wolfi-base:latest + EXPOSE 8080 + COPY --link --from=graalvm /home/app/application /app/application + ENTRYPOINT ["/app/application"]""".stripIndent().trim() when: def result = build "optimizedDockerBuildNative" diff --git a/functional-tests/src/test/groovy/io/micronaut/gradle/docker/DockerNativeFunctionalTest.groovy b/functional-tests/src/test/groovy/io/micronaut/gradle/docker/DockerNativeFunctionalTest.groovy index 5b34d06d..16395fe8 100644 --- a/functional-tests/src/test/groovy/io/micronaut/gradle/docker/DockerNativeFunctionalTest.groovy +++ b/functional-tests/src/test/groovy/io/micronaut/gradle/docker/DockerNativeFunctionalTest.groovy @@ -1,6 +1,5 @@ package io.micronaut.gradle.docker -import io.micronaut.gradle.AbstractGradleBuildSpec import io.micronaut.gradle.DefaultVersions import io.micronaut.gradle.fixtures.AbstractEagerConfiguringFunctionalTest import org.gradle.testkit.runner.TaskOutcome @@ -8,7 +7,7 @@ import spock.lang.IgnoreIf import spock.lang.Issue import spock.lang.Requires -@Requires({ AbstractGradleBuildSpec.graalVmAvailable }) +@Requires({ graalVmAvailable }) @IgnoreIf({ os.windows }) class DockerNativeFunctionalTest extends AbstractEagerConfiguringFunctionalTest { @@ -581,23 +580,22 @@ micronaut: then: dockerFile == """ -FROM ghcr.io/graalvm/native-image-community:17-ol${DefaultVersions.ORACLELINUX} AS graalvm -WORKDIR /home/alternate -COPY --link layers/libs /home/alternate/libs -COPY --link layers/app /home/alternate/ -COPY --link layers/resources /home/alternate/resources -RUN mkdir /home/alternate/config-dirs -RUN mkdir -p /home/alternate/config-dirs/generateResourcesConfigFile -RUN mkdir -p /home/alternate/config-dirs/io.netty/netty-common/4.0.0.Final -COPY --link config-dirs/generateResourcesConfigFile /home/alternate/config-dirs/generateResourcesConfigFile -COPY --link config-dirs/io.netty/netty-common/4.0.0.Final /home/alternate/config-dirs/io.netty/netty-common/4.0.0.Final -RUN native-image --exclude-config .*/libs/netty-transport-4.0.0.Final.jar ^/META-INF/native-image/.* --exclude-config .*/libs/netty-buffer-4.0.0.Final.jar ^/META-INF/native-image/.* --exclude-config .*/libs/netty-codec-http-4.0.0.Final.jar ^/META-INF/native-image/.* --exclude-config .*/libs/netty-handler-4.0.0.Final.jar ^/META-INF/native-image/.* --exclude-config .*/libs/netty-common-4.0.0.Final.jar ^/META-INF/native-image/.* --exclude-config .*/libs/netty-codec-http2-4.0.0.Final.jar ^/META-INF/native-image/.* -cp /home/alternate/libs/*.jar:/home/alternate/resources:/home/alternate/application.jar --no-fallback -o application -H:ConfigurationFileDirectories=/home/alternate/config-dirs/generateResourcesConfigFile,/home/alternate/config-dirs/io.netty/netty-buffer/4.0.0.Final,/home/alternate/config-dirs/io.netty/netty-common/4.0.0.Final,/home/alternate/config-dirs/io.netty/netty-codec-http/4.0.0.Final,/home/alternate/config-dirs/io.netty/netty-transport/4.0.0.Final,/home/alternate/config-dirs/io.netty/netty-handler/4.0.0.Final,/home/alternate/config-dirs/io.netty/netty-codec-http2/4.0.0.Final example.Application -${defaultDockerFrom} -EXPOSE 8080 -HEALTHCHECK CMD curl -s localhost:8090/health | grep '"status":"UP"' -COPY --link --from=graalvm /home/alternate/application /app/application -ENTRYPOINT ["/app/application", "-Xmx64m"] -""".trim() + FROM ghcr.io/graalvm/native-image-community:17-ol9 AS graalvm + WORKDIR /home/alternate + COPY --link layers/libs /home/alternate/libs + COPY --link layers/app /home/alternate/ + COPY --link layers/resources /home/alternate/resources + RUN mkdir /home/alternate/config-dirs + RUN mkdir -p /home/alternate/config-dirs/generateResourcesConfigFile + RUN mkdir -p /home/alternate/config-dirs/io.netty/netty-common/4.0.0.Final + COPY --link config-dirs/generateResourcesConfigFile /home/alternate/config-dirs/generateResourcesConfigFile + COPY --link config-dirs/io.netty/netty-common/4.0.0.Final /home/alternate/config-dirs/io.netty/netty-common/4.0.0.Final + RUN native-image --exclude-config .*/libs/netty-transport-4.0.0.Final.jar ^/META-INF/native-image/.* --exclude-config .*/libs/netty-common-4.0.0.Final.jar ^/META-INF/native-image/.* --exclude-config .*/libs/netty-codec-http2-4.0.0.Final.jar ^/META-INF/native-image/.* --exclude-config .*/libs/netty-buffer-4.0.0.Final.jar ^/META-INF/native-image/.* --exclude-config .*/libs/netty-codec-http-4.0.0.Final.jar ^/META-INF/native-image/.* --exclude-config .*/libs/netty-handler-4.0.0.Final.jar ^/META-INF/native-image/.* -cp /home/alternate/libs/*.jar:/home/alternate/resources:/home/alternate/application.jar --no-fallback -o application -H:ConfigurationFileDirectories=/home/alternate/config-dirs/generateResourcesConfigFile,/home/alternate/config-dirs/io.netty/netty-buffer/4.0.0.Final,/home/alternate/config-dirs/io.netty/netty-common/4.0.0.Final,/home/alternate/config-dirs/io.netty/netty-codec-http/4.0.0.Final,/home/alternate/config-dirs/io.netty/netty-transport/4.0.0.Final,/home/alternate/config-dirs/io.netty/netty-handler/4.0.0.Final,/home/alternate/config-dirs/io.netty/netty-codec-http2/4.0.0.Final example.Application + FROM cgr.dev/chainguard/wolfi-base:latest + EXPOSE 8080 + HEALTHCHECK CMD curl -s localhost:8090/health | grep '"status":"UP"' + COPY --link --from=graalvm /home/alternate/application /app/application + ENTRYPOINT ["/app/application", "-Xmx64m"]""".stripIndent().trim() when: def result = build ":dockerBuildNative" diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index cac93891..32391fb5 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -5,18 +5,19 @@ docker = "9.4.0" diffplug = "3.44.0" shadow = "8.1.1" groovy = "3.0.20" -spock = "2.1-groovy-3.0" +spock = "2.3-groovy-3.0" oraclelinux = "9" graalvmPlugin = "0.10.1" -micronaut-platform = "4.2.1" # This is the platform version, used in our tests -micronaut-aot = "2.2.0" -micronaut-testresources = "2.3.3" -micronaut-openapi = "6.5.1" mockserver = "5.15.0" log4j2 = { require = "2.17.1", reject = ["]0, 2.17["] } jetbrains-annotations = "24.1.0" tomlj = "1.1.1" +micronaut-platform = "4.3.3" # This is the platform version, used in our tests +micronaut-aot = "2.2.0" +micronaut-testresources = "2.3.3" +micronaut-openapi = "6.6.2" + [libraries] # Core micronaut-platform = { module = 'io.micronaut.platform:micronaut-platform', version.ref = 'micronaut-platform' } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1af9e093..a80b22ce 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew.bat b/gradlew.bat index 6689b85b..7101f8e4 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail