本文主要研究一下jib自定義entrypoint的用場java
<plugin> <groupId>com.google.cloud.tools</groupId> <artifactId>jib-maven-plugin</artifactId> <version>0.9.10</version> <configuration> <container> <ports> <port>8080</port> </ports> <useCurrentTimestamp>true</useCurrentTimestamp> <entrypoint> <arg>/bin/sh</arg> <arg>-c</arg> <arg>java ${JAVA_OPTS} -cp /app/resources/:/app/classes/:/app/libs/* com.example.JibDemoApplication</arg> </entrypoint> </container> <from> <image>java:8u172-jre-alpine</image> </from> <to> <image>jib-demo:${maven.build.timestamp}</image> </to> <allowInsecureRegistries>true</allowInsecureRegistries> <extraDirectory>${project.basedir}/src/main/jib</extraDirectory> </configuration> </plugin>
"Entrypoint": [ "java", "-Xms512m", "-cp", "/app/resources/:/app/classes/:/app/libs/*", "com.example.JibDemoApplication" ]
這種模式貌似不能支持環境變量,所以需改成沒有引號的模式,使用sh -c java命令來啓動git
docker run -p 8080:8080 -e JAVA_OPTS='-Xms512m -Xmx512m' --rm jib-demo:20180903
這樣就能夠順利使用JAVA_OPTS環境變量來配置JVM了github
jib的自定義entrypoint是0.9.10及以上版本才支持的,若須要自定義entrypoint,請先升級jib版本。docker