ABCD custom entrypoint

Posted by Adrianphp on Mon, 06 Jan 2020 01:09:57 +0100

order

This paper focuses on the use of jib custom entrypoint

maven

			<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>
  • Here, the entrypoint is customized under the container tag, and then the environment variables are injected, so that the configuration of the jvm is not written in the pom file
  • The original entry point generated by jib by default is in quotation mark mode, such as
"Entrypoint": [
                "java",
                "-Xms512m",
                "-cp",
                "/app/resources/:/app/classes/:/app/libs/*",
                "com.example.JibDemoApplication"
            ]

This mode does not seem to support environment variables, so you need to change it to the mode without quotation marks, and use the SH-C Java command to start it

Function

docker run -p 8080:8080 -e JAVA_OPTS='-Xms512m -Xmx512m' --rm jib-demo:20180903

In this way, you can successfully use the Java? Opts environment variable to configure the JVM

Summary

The customized entrypoint of jib is supported only when it is 0.9.10 or above. If you need to customize entrypoint, please upgrade the version of jib first.

doc

Topics: Java Maven jvm Google