skip to Main Content

I’m new to gradle kotlin and micronaut. by following the official guide create your first micronaut app gradle kotlin I made it run OK on my mac M1, but the task to generate the docker image fails:

Could not build image: no matching manifest for linux/arm64/v8 in the manifest list entries

this is expected I guess: by looking at the generated Dockerfile this is what I get:

FROM openjdk:17-alpine
WORKDIR /home/app
COPY layers/libs /home/app/libs
COPY layers/classes /home/app/classes
COPY layers/resources /home/app/resources
COPY layers/application.jar /home/app/application.jar
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "/home/app/application.jar"]

so an explicit platform should be specified along with the FROM.
If I got it right, micronaut’s plugin uses Gradle Docker Plugin, but I’m not finding the right piece of instruction to override the original from assertion that it generates.

2

Answers


  1. Following the documentation:

    The default uses an openjdk:17-alpine base image, however you can easily switch the base image to use by using the baseImage property of the dockerfile task:

    tasks.named("dockerfile") {
     baseImage = "oracle/graalvm-ce:22.2.0-java11"
    }
    
    Login or Signup to reply.
  2. The problem with the default settings of the Micronaut Gradle plugin is, that it uses openjdk:17-alpine as a base image. This image is only available for amd64 architectures. Your M1 Mac would like aarch64.

    Here is how I solved the problem with my projects.

    tasks.named("dockerfile") {
        baseImage = "eclipse-temurin:17.0.5_8-jre-jammy"
    }
    

    This will work on aarch64 (aka arm64) and amd64.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search