paketo-buildpacks / java-native-image

A Cloud Native Buildpack with an order definition suitable for Java native image applications
Apache License 2.0
28 stars 3 forks source link

Add support for static compilation with native-image #650

Open cforce opened 1 year ago

cforce commented 1 year ago

To compile full static native-images the MUSL CC is neded on the linux os which runs the native-image compile Provide support with liberica-openjdk-alpine-musl as packet buildpack ( https://registry.hub.docker.com/r/bellsoft/liberica-openjdk-alpine-musl)

<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
  <configuration>
    <image>
      <buildpacks>
        <buildpack>gcr.io/paketo-buildpacks/bellsoft-liberica:${bellsoft-liberica.version}</buildpack>
        <buildpack>gcr.io/paketo-buildpacks/java-native-image</buildpack>
      </buildpacks>
    </configuration>
</plugin>

Also see https://github.com/paketo-buildpacks/java-native-image/issues/507

dmikusa commented 1 year ago

This would require a new buildpack to install the MUSL build tools. I'm OK leaving this open as a placeholder though.

dmikusa commented 1 year ago

Moving this and changing this as a request to enable support for static compilation with native image.

Off the top of my head, this will require adding the MUSLC build tools. One way would be to create a buildpack that contributes to the MUSLC build tools. Another would be to use an extension and have them installed with the native package manager. Aside from that, we might want to add a flag to the native-image buildpack that makes setting the required arguments easier. Like BP_NATIVE_IMAGE_STATIC=true|false.

See https://github.com/paketo-buildpacks/java-native-image/issues/507#issuecomment-1307467973 for more background.