Jib: Gradle integration with the Application Plugin

Created on 31 Oct 2018  路  7Comments  路  Source: GoogleContainerTools/jib

In Gradle it might be nice to integrate with the Application Plugin.

A similar project, com.bmuschko.docker-java-application, does this. This makes com.bmuschko.docker-java-application very convenient to use for java projects that are already using the Application Plugin.

kinquestion

Most helpful comment

Hi @devinrsmith , thanks for sharing the example. From what I see configurable on the Gradle application plugin, we can consider supporting automatic detection of the following configuration:

run.main/mainClassName - Jib can use as the container.mainClass
run.jvmArgs/applicationDefaultJvmArgs - Jib can use as the container.jvmFlags
run.args - Jib can use as the container.args
run.environment - use as container.environment
run.debug - true can have Jib automatically add debugging agentlib to java invocation
run.minHeapSize/maxHeapSize - set -Xms/-Xmx
run.systemProperties - can add as -D JVM flags

We'll definitely need to look into this more and consider the side effects of automatically inferring these from the application plugin. @GoogleContainerTools/java-tools

All 7 comments

Hi @devinrsmith can you elaborate a little on how you think this might look?

Interesting. Seems like the com.bmuschko.docker-* series plugins can do some similar things as Jib does.

Sure. Here's an example project that I setup. Docker Gradle Application Example

I like to keep my "this is an application" logic separate from the image building / image publishing. IE, in the example I've linked, the applications app1 and app2 know they are applications, but don't know anything about images, docker, etc.

Having the root project apply the plugin com.bmuschko.docker-java-application and docker.javaApplication.tag to the application subprojects is all that is necessary to containerize them! It creates the appropriate images via calls to the docker daemon. The plugin can also publish/push images with proper authentication.

(You can view Dockerfile workflow by inspecting app1/build/docker or app2/build/docker to see that plugin's take on containerizing the application structure.)

One thing that I don't like is having a dependency on docker, which it seems like Jib gets rid of.

I'd be very happy if Jib could produce the same, or similar, images that the above plugin can. (Of course, without the dependency on Docker, it's appropriate to either create jib-image.tar or publish the image to a registry.) I'm sure there is a way to use some gradle foo with Jib + application to achieve the same results, but it's nice to have it built-in.

Hi @devinrsmith , thanks for sharing the example. From what I see configurable on the Gradle application plugin, we can consider supporting automatic detection of the following configuration:

run.main/mainClassName - Jib can use as the container.mainClass
run.jvmArgs/applicationDefaultJvmArgs - Jib can use as the container.jvmFlags
run.args - Jib can use as the container.args
run.environment - use as container.environment
run.debug - true can have Jib automatically add debugging agentlib to java invocation
run.minHeapSize/maxHeapSize - set -Xms/-Xmx
run.systemProperties - can add as -D JVM flags

We'll definitely need to look into this more and consider the side effects of automatically inferring these from the application plugin. @GoogleContainerTools/java-tools

There might be a few other places as well. The gradle application plugin also applies the distribution plugin. One thing that the distribution plugin does is include the src/$distribution.name/dist (documented here) in the output, it seems very similar to what jib does with src/main/jib.

Any update on this, please? It would be very convenient if jib defaults fallback to settings from the application plugin.

I'm also willing to prepare a PR if it's desired feature.

For anyone interested in this: please submit a design proposal first.

Was this page helpful?
0 / 5 - 0 ratings