Baking a Docker container with GraalVM
Earlier in this chapter, we installed GraalVM’s OpenJDK distribution and built our native application locally. But that’s not the only way, nor is it always the ideal way.
For example, if we plan to run our application on a cloud configuration based on Linux, then building an application locally on a MacBook Pro or a Windows machine won’t do.
In Chapter 7, Releasing an Application with Spring Boot, we learned how to use ./mvnw spring-boot:build-image
and let a Paketo Buildpack assemble our application into a Docker container. We can use something similar to build a native application inside a Docker container.
Just run the following command:
% ./mvnw -Pnative spring-boot:build-image
This combines the previous chapter’s spring-boot:build-image
command with the native
Maven profile.
This process may take even longer than building the native application locally, but the benefit is that, when completed...