Source: Build containers faster with Cloud Build with Kaniko from Google Cloud
At Google, we believe that fast builds are key to developer productivity. A recent internal study showed that our largest source of wasted engineering time comes from builds that take 2-10 minutes. We’re not the only ones to notice this. In another study, Stripe found that companies waste $300 billion from lost developer productivity every year. And most importantly, our customers notice this as well! Faster builds and caching have been some of the most requested features for Cloud Build since we launched it in July.
Today, we’re excited to announce a new feature for Cloud Build that caches container build artifacts, resulting in much faster build times. Based on Kaniko, an open-source tool for building container images from a Dockerfile, this feature stores and indexes intermediate layers inside of Google Container Registry, so they are available for use by subsequent builds. This feature is available for testing in Cloud SDK Release 229.0.0.
To try it out, run:
and then (from a directory with a Dockerfile in it) send a build with:
This cache is based on the exact Dockerfile and source context used by the build, and follows the general Dockerfile caching patterns. To learn more about how to optimize a Dockerfile for caching, see this documentation on leveraging the build cache. This cache is scoped on a "per-repository" basis, and has a six-hour TTL by default. This can be configured by running:
You can also use Kaniko instead of "docker build" in your cloudbuild.yaml config to take advantage of these caching improvements:
This is one of the first of many features we're rolling out in Cloud Build to automatically make your builds faster, smarter and more secure. Please try it out and let us know if you have any feedback by joining the Kaniko users Google Group.