Jx: Support multi layer optimization of java application images

Created on 2 Nov 2018  路  12Comments  路  Source: jenkins-x/jx

Summary

When creating docker images for Java applications in the current setup in Jenkins-X the application and all dependencies are all placed in one jar file, meaning it will be in one layer in the docker image.

This means that when new versions of the application are created the unchanged dependencies can't be reused.

It would be a great enhancement if the application code where put in a separate, top, layer so the lower layers could be reused: the time to create the image would be reduced, the push to the registry would be faster and the disk usage in both the docker engine and the docker registry would be reduced.

References

https://github.com/gclayburg/dockerPreparePlugin
https://openliberty.io/blog/2018/07/02/creating-dual-layer-docker-images-for-spring-boot-apps.html

arebuild good first issue kinenhancement prioritimportant-longterm

Most helpful comment

JIB is probably the solution with largest traction:
https://github.com/GoogleContainerTools/jib

When using this for java build it essentially means skaffold is replaced with jib.

All 12 comments

JIB is probably the solution with largest traction:
https://github.com/GoogleContainerTools/jib

When using this for java build it essentially means skaffold is replaced with jib.

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close.
Provide feedback via https://jenkins-x.io/community.
/lifecycle stale

/remove-lifecycle stale

I'd love to tackle this issue. Is it still relevant?

As far as I can see it's as relevant as before. I'm not employed by Cloudbees though, so there might be things going on that I don't know about.

A word of caution: I'm not sure this is a good first issue; it involves changes in at least 2 repositories. This is what I think is needed:

Draft packs for building java applications need changes to pipelines.yaml (I think) and skaffold.yaml (Dockerfile can be removed). See https://github.com/GoogleContainerTools/skaffold/tree/master/examples/jib about the integration of skaffold and Jib. Also Jib needs to be configured in pom.xml / build.gradle. For this to be smooth for the user the addition of the Jib build plugin should preferably be done automatically by jx import. For maven this could be done in jx (method fixMaven in pkg/cmd/importcmd/import.go) for gradle I don't know of a any existing mechanism. For the gradle case you could at least change the quickstarts that use gradle.

I would start with the maven-java11 draft pack so you can use of the automatic update of pom.xml and also avoid the need to change the default jvm flags since the memory settings of java 11 are sensible for docker by default.

It would probably be a good idea to discuss this on Slack or at the office hours since it's a fairly big change.

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close.
Provide feedback via https://jenkins-x.io/community.
/lifecycle stale

/remove-lifecycle stale

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close.
Provide feedback via https://jenkins-x.io/community.
/lifecycle stale

/remove-lifecycle stale

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close.
Provide feedback via https://jenkins-x.io/community.
/lifecycle stale

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
If this issue is safe to close now please do so with /close.
Provide feedback via https://jenkins-x.io/community.
/lifecycle rotten

/remove-lifecycle rotten

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tdcox picture tdcox  路  3Comments

igdianov picture igdianov  路  3Comments

CobraFlow picture CobraFlow  路  5Comments

shahnewazrifat picture shahnewazrifat  路  3Comments

kevinsuperped picture kevinsuperped  路  5Comments