micronaut-projects / micronaut-gradle-plugin

A Gradle Plugin for Micronaut
Apache License 2.0
66 stars 44 forks source link

Not able to setup aarch64 based native images #400

Open aniljaiswal opened 2 years ago

aniljaiswal commented 2 years ago

Due to the platform architecture being hardcoded in the setup instructions, I'm not able to build native images on Mac OS running on M1 (aarch64). Snippet attached below:

https://github.com/micronaut-projects/micronaut-gradle-plugin/blob/96f4a5fc28e2f7b443a922b0888de3c9b5811a1a/docker-plugin/src/main/java/io/micronaut/gradle/docker/NativeImageDockerfile.java#L360

Just like other params being configurable, the platform should also be user-configurable and a fallback should be used when not provided.

kastork commented 2 years ago

I've got the example project for r2dbc almost building... it gets to the step where the docker build wants to install libstdc++ on the alpine container

Produced artifacts:
 /home/app/application (executable)
 /home/app/application.build_artifacts.txt
========================================================================================================================
Finished generating 'application' in 2m 8s.
Removing intermediate container 33510fcaf6ab
 ---> 8e4137567893
Step 10/13 : FROM frolvlad/alpine-glibc:alpine-3.12
 ---> 15b73cac1129
Step 11/13 : RUN apk update && apk add libstdc++
 ---> [Warning] The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
 ---> Running in 94084aa51d69
standard_init_linux.go:228: exec user process caused: exec format error

Not sure where to go from there.

I believe the root problem is the same one discussed in #365

I should mention, this isn't limited to graalvm native builds, it happens in regular docker builds too.