however every time i rebuild the image if there is change in the packeto buildpack (in git) it downloads the entire packeto builder consuming unnecessary space of my disk.
A few notes here:
When Docker downloads an image, it's smart about it. It will only download layers that have changed. It's hard to say how much this will save every time it downloads, but not everything will change between builder versions.
The builder consists of the build image and layers for the buildpacks in that builder. If for example, some of the build packs do not change between builder versions then it wouldn't need to download all of them again.
tl;dr - it may not be as bad as you think.
It is fetching a new builder every time because you ideally want to have the most recent software when you are building new images. The builder contains libraries that are used at build time, and the buildpacks themselves.
If, for example, the Bellsoft Liberica buildpack is updated with the latest OpenJDK release, you will need to download the latest builder so that you get that update the next time your app is compiled and an image built.
You can docker system prune
to quickly clean up unused containers & images. That will reduce disk usage after updates are pulled.
how can i avoid this by specifying only specific tag so each update of packeto in git is not pulled in my image.
You have a couple options here:
You can set the pull policy. It defaults to "always". You would want "if not present". This would instruct Spring Boot build tools to download the build/run images if they do not exist. If they exist locally, then they won't be downloaded again.
Ex:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<image>
<pullPolicy>IF_NOT_PRESENT</pullPolicy>
</image>
</configuration>
</plugin>
You can specify a specific builder image. It's similar to #1, just set the builder image & tag.
Ex:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<image>
<builder>paketobuildpacks/builder:0.1.115-base</builder>
</image>
</configuration>
</plugin>
For reference on both of these, see the settings here: https://docs.spring.io/spring-boot/docs/2.5.1/maven-plugin/reference/htmlsingle/#build-image
CAUTION: You want to be careful with both of these options because they can result in you building images with older builder images and thus older buildpacks. They won't automatically update. This can leave your images built based off of older libraries or older dependencies like JVM versions. Just something to keep in mind.