weixin_40001372 2020-11-21 15:42
浏览 1

Create a custom runtime image with `jlink`

The benefits of creating a custom runtime image are:

  • [x] Reduction of the number of requirements
  • [x] Minimizing the size of the Docker image
  • [x] Less friction with new users

该提问来源于开源项目:fonoster/routr

  • 写回答

5条回答 默认 最新

  • weixin_40001372 2020-11-21 15:42
    关注

    The following steps can be used to create a custom run-time image:

    1. Get the jmods list for the server's dependency with $JAVA_HOME/bin/jdeps --list-deps libs/app.deps.jar

    2. Run jlink agains the module list:

    bash
    jlink -c --no-man-pages --no-header-files -G \
    --module-path $JAVA_HOME/jmods/ \
    --add-modules \
    jdk.scripting.nashorn,\
    jdk.scripting.nashorn.shell,\
    java.base,\
    java.compiler,\
    java.instrument,\
    java.logging,\
    java.management,\
    java.naming,\
    java.scripting,\
    java.security.jgss,\
    java.xml,\
    java.xml.bind,\
    java.sql,\
    java.rmi,\
    jdk.sctp \
    --output jre
    

    Or in Windows

    batch
    jlink.exe --output jre-window -c --no-man-pages --no-header-files -G `
    --module-path %JAVA_HOME%/jmods `
    --add-modules jdk.scripting.nashorn,jdk.scripting.nashorn.shell,java.base,java.compiler,java.instrument,java.logging,java.management,java.naming,java.scripting,java.security.jgss,java.xml,java.xml.bind,java.sql,java.rmi,jdk.sctp
    

    Additional testing must be done to create platform-specific images. Also, the base image for "sipio-docker" does not support JDK9 yet, which makes this task slightly difficult.

    评论

报告相同问题?