Allow to use jib instance as base-image in multi-project builds
See original GitHub issueThis is a follow-up on #1436 (Optimize Layering for Multi-Project Setups). In Gradle multi-project people typically build and deploy many (micro)services. Accordingly many Docker images are being built. In most cases those images will share a great amount of the techstack and only differ in the business functionality. Accordingly it would make sense to introduce a shared base layer holding third-party dependencies that are shared by all projects, whereas the individual projects only hold the delta to those base images. This could look like:
dependencies{
compile project(':service-base')
jibBaseImage project(':service-base')
}
whereas service-base
holds all the third-party dependencies necessary for the various projects. This would trigger for a service project:
- use of
service-base
as base layer of the Docker image (no need to specify one) - exclusion of all dependencies of :service-base in the built image.
- check whether there is any dependency version mismatch whereas the service changes the version of a third-party library => services should not be able to overrule the version of the base image to avoid having the same JAR twice in the image.
- the jibTasks like
jib
setup proper dependencies. - the jibTasks access the cache directory of the
service-base
to fetch the built artifacts.
The jib instance in service-base
would be a regular jib instance.
Layering of Docker images has been discussed in other tickets like https://github.com/GoogleContainerTools/jib/issues/403. While a simple/pragmatic solution has been implemented, it does fully address the brought up issues that desires to have more control of the layering. With this ticket here rather advanced layering can be setup transparently in a traditional “Gradle/Maven-way” without having to deal with inner workings of Docker layering or having to manually specify which third-party libraries go into which layer.
as a further benefit the multiple jib instances automatically will be “in-sync” in terms of caching, whereas the actual base layer (some JRE image) will only be downloaded once by service-base
.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
Our application looks like:
Gradle up-to-date checking, caching, size of build artifacts and incremental updates of Kubernetes are one of our primary concerns/goals in the area to make it efficiently even tough the project is larger in size. We do not want to split up the project into many small parts and have to start versioning and manage them independently as it would drastically increase our efforts. Over the past months I created a number of tickets to make it work. It works in general, but the little things still hurt. This one being a primary one.
close as not planned