Skip to content
This repository was archived by the owner on Feb 23, 2023. It is now read-only.

Document how to generate a native image from Spring Boot executable JAR #736

Closed
sergey-morenets opened this issue Apr 14, 2021 · 6 comments
Assignees
Labels
type: documentation A documentation task
Milestone

Comments

@sergey-morenets
Copy link

Hi

We would like to generate native image by native-image utility in Dockerfile:

native-image -jar custom-spring-boot.jar

But it seems that in generated fat jar META-INF/native-image folder is not root as described in GraalVM documentation:
https://docs.oracle.com/en/graalvm/enterprise/20/docs/reference-manual/native-image/BuildConfiguration/

It's located under BOOT-INF/classes and native-image is unable to detect it. Whereas Micronaut (and Micronaut plugins) create META-INF/native-image in the root folder in the generated jar.
So the question is: is it possible to generate GraalVM native image (using plugin or by another approach)?

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Apr 14, 2021
@sdeleuze sdeleuze added type: question A question and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Apr 15, 2021
@sdeleuze sdeleuze changed the title Unable to generate native image explicitly Generate a native image from Spring Boot executable JAR Apr 15, 2021
@sdeleuze sdeleuze added status: waiting-for-triage An issue we've not yet triaged or decided on and removed type: question A question labels Apr 15, 2021
@sdeleuze
Copy link
Contributor

sdeleuze commented Apr 15, 2021

native-image does not recognize Spring Boot executable JAR format, and we currently provide 2 ways of creating native images via build plugins as documented here.

That said, native image creation being designed to be run on CI/CD platform and given the fact that most containers are CPU architecture specific, I see some value in providing the capability to turn a Spring Boot executable JAR to a native image. Just not sure how we could/should implement that.

Any thoughts @bclozel @snicoll @aclement ?

@sdeleuze
Copy link
Contributor

sdeleuze commented Apr 15, 2021

Maybe pack already allows to do that via https://github.com/paketo-buildpacks/native-image ?

@sergey-morenets
Copy link
Author

native-image does not recognize Spring Boot executable JAR format, and we currently provide 2 ways of creating native images via build plugins as documented here.

That said, native image creation being designed to be run on CI/CD platform and given the fact that most containers are CPU architecture specific, I see some value in providing the capability to turn a Spring Boot executable JAR to a native image. Just not sure how we could/should implement that.

Any thoughts @bclozel @snicoll @aclement ?

Yes, that's correct. But spring-boot:build-image goal generates OCI image with native image application. Sometimes I want to build OCI (Docker) image by myself. In that case I just need a goal to compile native image but Spring Boot plugin doesn't support that now.

@sdeleuze
Copy link
Contributor

For that you can use native-image-maven-plugin documented here.

@sdeleuze sdeleuze added type: question A question and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Apr 15, 2021
@sergey-morenets
Copy link
Author

@sdeleuze

Yes, but I will get fallback image, because unfortunately Native Image Builder doesn't recognize and support Spring Boot JAR Layout. So I will need JDK/JRE to run it.

@sdeleuze
Copy link
Contributor

I mean from sources not the executable JAR (btw we disable fallback in Spring Native).
From executable JAR, you should be able to generate a container image (follow #738). I am discussing with the GraalVM team if we should or not supporting generating a native image from a Spring Boot executable JAR, I will reopen this issue if we decide to support that.

@sdeleuze sdeleuze added type: documentation A documentation task and removed type: question A question labels Apr 27, 2021
@sdeleuze sdeleuze self-assigned this Apr 27, 2021
@sdeleuze sdeleuze added this to the 0.10.0 milestone Apr 27, 2021
@sdeleuze sdeleuze reopened this Apr 27, 2021
@sdeleuze sdeleuze changed the title Generate a native image from Spring Boot executable JAR Document how to generate a native image from Spring Boot executable JAR Apr 27, 2021
snicoll added a commit that referenced this issue Apr 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: documentation A documentation task
Development

No branches or pull requests

3 participants