Search code examples
github-actionsgraalvmgraalvm-native-imagejib

How to associate JIB and GraalVM


Introduction

I'm currently working on a GitHub CI that automatically builds a container with the JIB buildpack.

And I wonder if it is possible to combine JIB and GraalVM to build a native solution?

The code of the CI:

jobs:
  publish:

    runs-on: ubuntu-latest
    
    steps:

    - name: downcase IMAGE_NAME
      run: |
        echo "IMAGE_NAME=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV}
    - uses: actions/checkout@v2
    - name: Set up JDK 17
      uses: actions/setup-java@v2
      with:
        distribution: 'adopt'
        java-version: 17

    - name: Buil JIB container and publish to GitHub Packages
      run: |
       mvn compile com.google.cloud.tools:jib-maven-plugin:3.1.4:build \
       -Djib.to.image=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.event.release.tag_name }} \
       -Djib.to.auth.username=${{ env.USERNAME }} \
       -Djib.to.auth.password=${{ env.PASSWORD }} \
       -Djib.from.image=azul/zulu-openjdk:17-jre-headless

Question

Do you think it is possible to combine JIB and GraalVM in this case? If so, how can we do this?


Solution

  • Jib has an extension for Maven called jib-native-image-extension-maven which containerizes a native image. However, note that it relies on the Native Maven Plugin to do the work of building an executable for the application. The Jib extension mainly copies it into a container image and sets the image entrypoint to the binary (if not manually configured). Here are more instructions on how the extension can be applied.