diff --git a/docker-plugin/src/main/java/io/micronaut/gradle/docker/NativeImageDockerfile.java b/docker-plugin/src/main/java/io/micronaut/gradle/docker/NativeImageDockerfile.java index 68fe760f..99557dec 100644 --- a/docker-plugin/src/main/java/io/micronaut/gradle/docker/NativeImageDockerfile.java +++ b/docker-plugin/src/main/java/io/micronaut/gradle/docker/NativeImageDockerfile.java @@ -57,6 +57,8 @@ */ public abstract class NativeImageDockerfile extends Dockerfile implements DockerBuildOptions { + public static final String AMAZON_LINUX_BASE_IMAGE = "public.ecr.aws/amazonlinux/amazonlinux:" + DefaultVersions.AMAZONLINUX; + private static final List SUPPORTED_JAVA_VERSIONS = List.of( // keep those in descending order 21, @@ -458,7 +460,7 @@ private void setupInstructions(List additionalInstructions) { if (buildStrategy == DockerBuildStrategy.LAMBDA) { from(new From(imageResolver.resolve()).withStage("graalvm")); environmentVariable("LANG", "en_US.UTF-8"); - runCommand("yum install -y gcc gcc-c++ glibc-devel glibc-langpack-en curl-minimal bash zlib zlib-devel zlib-static zip tar gzip"); + runCommand("dnf update -y && dnf install -y gcc glibc-devel zlib-devel libstdc++-static tar && dnf clean all && rm -rf /var/cache/dnf"); String jdkVersion = getJdkVersion().get(); String graalArch = getGraalArch().get(); // https://download.oracle.com/graalvm/17/latest/graalvm-jdk-17_linux-aarch64_bin.tar.gz @@ -475,6 +477,7 @@ private void setupInstructions(List additionalInstructions) { defaultCommand("/usr/lib/graalvm/bin/native-image"); environmentVariable("PATH", "/usr/lib/graalvm/bin:${PATH}"); from(new From("graalvm").withStage("builder")); + runCommand("dnf update -y && dnf install -y zip && dnf clean all"); } else { from(new From(getGraalImage().get()).withStage("graalvm")); } @@ -531,7 +534,7 @@ private void setupInstructions(List additionalInstructions) { case LAMBDA: from(baseImageProvider); workingDir("/function"); - runCommand("yum install -y zip"); + runCommand("dnf install -y zip"); copyFile(new CopyFile(workDir + "/application", "/function/func").withStage("builder")); String funcCmd = String.join(" ", getArgs().map(strings -> { List newList = new ArrayList<>(strings.size() + 1); @@ -771,7 +774,7 @@ private String resolve() { String baseImage = getBaseImage().getOrNull(); if (strategy == DockerBuildStrategy.LAMBDA && baseImage == null) { - baseImage = "amazonlinux:2023"; + baseImage = AMAZON_LINUX_BASE_IMAGE; } else if (baseImage == null) { baseImage = "cgr.dev/chainguard/wolfi-base:latest"; } 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 6568ab9f..df38a0c1 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 @@ -104,8 +104,8 @@ micronaut: where: runtime | jdk | nativeImage "netty" | 17 | "FROM ghcr.io/graalvm/native-image-community:17-ol${DefaultVersions.ORACLELINUX}" - "lambda_provided" | 17 | 'FROM amazonlinux:2023 AS graalvm' - "lambda_provided" | 21 | 'FROM amazonlinux:2023 AS graalvm' + "lambda_provided" | 17 | "FROM public.ecr.aws/amazonlinux/amazonlinux:${DefaultVersions.AMAZONLINUX} AS graalvm" + "lambda_provided" | 21 | "FROM public.ecr.aws/amazonlinux/amazonlinux:${DefaultVersions.AMAZONLINUX} AS graalvm" "jetty" | 17 | "FROM ghcr.io/graalvm/native-image-community:17-ol${DefaultVersions.ORACLELINUX}" } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index b17a8cf1..5f6dc97f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -7,6 +7,7 @@ shadow = "8.1.1" groovy = "3.0.22" spock = "2.3-groovy-3.0" oraclelinux = "9" +amazonlinux = "2023-minimal" graalvmPlugin = "0.10.3" mockserver = "5.15.0" log4j2 = "2.24.1" diff --git a/minimal-plugin/build.gradle b/minimal-plugin/build.gradle index c509c357..81dd166e 100644 --- a/minimal-plugin/build.gradle +++ b/minimal-plugin/build.gradle @@ -28,6 +28,7 @@ var writeVersions = tasks.register("writeDefaultVersions", WriteVersions) { versions.put('test-resources', libs.versions.micronaut.testresources) versions.put('openapi', libs.versions.micronaut.openapi) versions.put('oraclelinux', libs.versions.oraclelinux) + versions.put('amazonlinux', libs.versions.amazonlinux) packageName = 'io.micronaut.gradle' }