1

So we have a git repository that has a number of docker images (multiple Dockerfiles each of which used for a different type of application build in our Jenkins)

Now if one makes a change in one Dockerfile the Jenkins job will build and pushe all other Dockerfiles in the repository. I was wondering, if we were able to calcualte the digest id (SHA256) beforehand and compare that with our docker registry, if there is one already we can skip docker build and docker push.

I couldn't find any command in Docker user guide but here with this post I also wanted to know if we can raise a ticket for this new feature if this approach works and if there is no way of calculating this identifier

Any other suggestion is greatly appreciated

xbmono
  • 2,084
  • 2
  • 30
  • 50
  • You can't know the hash before you prepare content for its calculation (build the image). If nothing changed, intermediate layers will/should be fetched from the cache and image building will be quick. But if there were changes, you have to rebuild affected layers. – Sergio Tulentsev Dec 20 '18 at 23:52
  • okay any other suggestion on how to do this? – xbmono Dec 21 '18 at 03:05
  • I would try to tackle it on repository / jenkins level. Easiest solution: Split your repository along applications/Dockerfiles (1 Dockerfile = 1 application = 1 git-repo). Otherwise: Configure Jenkins to only build the affected subdirectory in your repository. This seems a bit hacky but [technically possible](https://stackoverflow.com/questions/44901004/how-to-only-build-one-directory-in-a-jenkins-multi-branch-pipeline-job) – Fabian Braun Dec 21 '18 at 09:20
  • @fab Thanks. Splitting the repo isn't an option at the moment unfortunately and we came up with something similar as the second option you mentioned. So we've decided to have a file name it version and every time we make a change the developer has to upgrade the version... we then check the changes being made against the file. – xbmono Jan 08 '19 at 05:48

0 Answers0