GoogleContainerTools / jib-extensions

Apache License 2.0
118 stars 35 forks source link

Add Native Image Jib Maven extension #33

Closed chanseokoh closed 4 years ago

chanseokoh commented 4 years ago

The extension assumes that the project is building a "native image" (a single executable binary) using the GraalVM's native-image-maven-plugin (source). The native-image plugin does the heavy lifting, so this extension just needs to locate and copy the executable.

Some more details,

I've consulted our previous https://github.com/GoogleContainerTools/jib/pull/2268 as well as the native-image-maven-plugin source.

We'll want to add an example too.


(from https://github.com/GoogleContainerTools/jib/pull/2268)

Things to do:

  • Check that the current platform matches the image
  • Figure out what to do with Gradle since there doesn't seem to be a definitive Gradle native-image plugin. Perhaps we can just make the executable path explicitly configurable.

General note about building a container image for a native image:

As explained in https://github.com/GoogleContainerTools/jib/pull/2268, the native-image binary should be built on the same architecture as the architecture used at runtime, since native-image doesn't support cross-compilation. Otherwise, you may get into a puzzling error:

$ docker run -it --rm native-hello
standard_init_linux.go:211: exec user process caused "exec format error"