is there a way to compare existing docker image with latest source (Git) and build it only when there is any code change?

Clash Royale CLAN TAG#URR8PPPis there a way to compare existing docker image with latest source (Git) and build it only when there is any code change?
I have a gradle task which creates a docker image using the product code in Git. When the task is run docker image is created and pushed to repository/hub. But I would like to have a check where I do it only when there is a code change compared with last/latest docker image.
1 Answer
1
One way of doing this would be to wrap your docker build in a shell script.
This script will build the image with a label whose value is the commit hash.
The script will also check the value of this label for the current image and will compare it with the current commit hash before building.
docker build
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.