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
Following the documentation:
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 foramd64
architectures. Your M1 Mac would likeaarch64
.Here is how I solved the problem with my projects.
This will work on
aarch64
(akaarm64
) andamd64
.