如何关联JIB和GraalVM

How to associate JIB and GraalVM

简介

我目前正在研究 GitHub CI,它会自动使用 JIB 构建包构建容器。

我想知道是否可以结合 JIB 和 GraalVM 来构建原生解决方案?

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

问题

您认为在这种情况下可以结合使用 JIB 和 GraalVM 吗?如果是这样,我们该怎么做?

Jib 有一个名为 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 的 Maven 扩展,介绍了如何应用该扩展。