Every layer is rebuild even if there is no source code change
See original GitHub issueI’m using jib-maven-plugin with version 3.1.2 and have the following added to my pom file:
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>3.1.2</version>
</plugin>
and I use the following command to build and push an image:
mvn compile jib:build -Dimage=eu.gcr.io/project_id/image_name -Djib.to.tags=latest,another_tag -Djib.from.image=eu.gcr.io/project_id/image_name
in my Github Actions CI/CD pipeline.
But even if I don’t have any source code changes all layers are rebuild and the image is pushed:
Getting manifest for base image eu.gcr.io/project_id/image_name...
[INFO] Building dependencies layer...
[INFO] Building resources layer...
[INFO] Building classes layer...
[INFO] Building jvm arg files layer...
To my understanding no layer should be rebuild since there was no change and if I only change a dependency then only the dependency layer should be rebuild etc. I also tried adding a specific image digest for the base image but that didn’t help.
Is something wrong with the above command or is it not possible to pull the latest image from Google Container Registry, use it as base image and then have only the layers be rebuild where a change was?
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
No rebuild after code change - Visual Studio Feedback
My project was migrated from VS2015 where it was compiling correctly for months. Under Visual Studio 2017, there are no problems after a...
Read more >How to configure VS to compile only changed code
A setup project for example will always rebuilt, even if there are no changes made (due to this fact I normally exclude the...
Read more >Watch code and automatically rebuild when something changes
Compose could watch your code and automatically kick off builds when something changes. This would mean: Code can be reloaded automatically regardless of ......
Read more >Incremental Dev Container Rebuild | GitHub Changelog
The rebuild behavior prior to this change was full rebuild, which is slower but guarantees correctness because it removes all images from the ......
Read more >Why Visual Studio keeps rebuilding my projects for no good ...
Did you ever feel like Visual Studio is rebuilding projects every single time, even when there were no changes to the code?
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You misunderstood what a base image is. It doesn’t make sense to set both
jib.from.image
andjib.to image
to the same image. You build a new image by adding layers of your application (classes, resources, …) on top of a base image. Then, what you did was to use that new image you just built as a base image and put the same application layers on top of that. That is, now you have duplicate layers. You have been repeating this process, and that is why your image size on GCR is progressively increasing.When you are not specifying a base image, the default Jib uses is
adoptopenjdk:8/11-jre
, but you can choose whatever JDK image that you think works best for you.Thank you for the detailed example and information.
I see that you didn’t include
-Djib.from.image=gcr.io/<GCP project>/foo
in your command. But in my case this is necessary right?Because how I understand it is that since I’m running Jib in my Github Actions workflow runs:
-Djib.from.image=eu.gcr.io/project_id/image_name
I’m pulling the latest image from GCR and use it as base imageUnfortunately that’s not what I’m experiencing. Here is how I’m running Jib in my workflow like mentioned in my first comment:
I just changed
Dimage
now toDjib.to.image
and removed the tags.I triggered my workflow 5 times (with dummy commits) and so I had Jib run 5 times. Here is the latest run:
In GCR I see that there is always a new image added/created and for some reason the virtual size increases every time by approx. 50MB
Do you have an idea why this is happening?