{"id":587,"date":"2025-06-19T15:14:25","date_gmt":"2025-06-19T06:14:25","guid":{"rendered":"https:\/\/tako.nakano.net\/blog\/?p=587"},"modified":"2025-06-22T16:59:20","modified_gmt":"2025-06-22T07:59:20","slug":"cloud-build-tips-part-1","status":"publish","type":"post","link":"https:\/\/tako.nakano.net\/blog\/2025\/06\/cloud-build-tips-part-1\/","title":{"rendered":"Cloud Build \u306e\u30ef\u30b6 \u305d\u306e1"},"content":{"rendered":"<h1>Cloud Build \u306e\u30ef\u30b6 \u305d\u306e1<\/h1>\n<p>English follows Japanese.<\/p>\n<h2>\u7d50\u8ad6<\/h2>\n<p><code>google-cloud-cli<\/code> \u3084 <code>cloud-sdk<\/code> \u306e\u4ee3\u308f\u308a\u306b <code>gcr.io\/cloud-builders\/gcloud<\/code> \u3092\u4f7f\u3046\u3060\u3051\u30671\u5206\u306e\u30d3\u30eb\u30c9\u6642\u9593\u304c\u77ed\u7e2e\u3067\u304d\u308b\u3002<br \/>\n\u305d\u306e\u4ed6\u3001\u300cCloud Build \u63d0\u4f9b\u306e\u30b5\u30dd\u30fc\u30c8\u3055\u308c\u3066\u3044\u308b\u30d3\u30eb\u30c0\u30fc \u30a4\u30e1\u30fc\u30b8\u300d\u3092\u77e5\u308b\u3068\u6642\u77ed\u3067\u304d\u308b\u3002<\/p>\n<h2>\u306f\u3058\u3081\u306b<\/h2>\n<p>\u307f\u306a\u3055\u3093\u3001Cloud Build \u3092\u4f7f\u3063\u3066\u3044\u307e\u3059\u304b\uff1f<br \/>\nCloud Build \u306f\u3001Google Cloud \u306e CI\/CD \u30b5\u30fc\u30d3\u30b9\u3067\u3059\u3002\u3044\u308d\u3044\u308d\u306a\u4f7f\u3044\u65b9\u304c\u3067\u304d\u307e\u3059\u304c\u3001\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u30d3\u30eb\u30c9\u3057\u3066\u3001\u30b3\u30f3\u30c6\u30ca\u30a4\u30e1\u30fc\u30b8\u3092\u4f5c\u6210\u3057\u3001\u30c7\u30d7\u30ed\u30a4\u3059\u308b\u305f\u3081\u306e\u5f37\u529b\u306a\u30c4\u30fc\u30eb\u3067\u3059\u3002<\/p>\n<p>Cloud Build \u306e\u300c\u904b\u7528\u300d\u306b\u304a\u3044\u3066\u3001\u3088\u304f\u8a71\u984c\u306b\u4e0a\u304c\u308b\u306e\u304c\u300c\u6642\u9593\u300d\u3067\u3059\u3002Cloud Build \u306e\u30d3\u30eb\u30c9\u6642\u9593\u3092\u77ed\u7e2e\u3059\u308b\u3068\u3001<\/p>\n<ol>\n<li>\u958b\u767a\u8005\u306e\u5f85\u3061\u6642\u9593\u304c\u6e1b\u308b<\/li>\n<li>\u30d3\u30eb\u30c9\u30b3\u30b9\u30c8\u304c\u4e0b\u304c\u308b<\/li>\n<\/ol>\n<p>\u3068\u3044\u3046\u30e1\u30ea\u30c3\u30c8\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u4eca\u56de\u306f\u3001\u30d3\u30eb\u30c9\u306e\u300c\u4e2d\u8eab\u306f\u5909\u3048\u305a\u300d\u306b\u3001\u30d3\u30eb\u30c9\u6642\u9593\u3060\u3051\u3092\u77ed\u7e2e\u3059\u308b\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<h2>\u8a73\u7d30<\/h2>\n<p>\u30d3\u30eb\u30c9\u30d7\u30ed\u30bb\u30b9\u5185\u3067\u306f\u3001\u3044\u308d\u3044\u308d\u306a\u30c4\u30fc\u30eb\u3092\u4f7f\u3046\u3053\u3068\u304c\u3042\u308b\u3068\u601d\u3044\u307e\u3059\u3002\u4e2d\u3067\u3082\u3001Google Cloud \u306e\u30ea\u30bd\u30fc\u30b9\u3092\u64cd\u4f5c\u3059\u308b\u305f\u3081\u306b <code>gcloud<\/code> \u30b3\u30de\u30f3\u30c9\u3092\u4f7f\u3046\u3053\u3068\u306f\u591a\u3044\u3067\u3057\u3087\u3046\u3002<\/p>\n<p>\u5b9f\u306f\u3001<code>gcloud<\/code> \u30b3\u30de\u30f3\u30c9\u3092\u63d0\u4f9b\u3059\u308b Google Cloud \u306e\u30a4\u30e1\u30fc\u30b8\u306f\u8907\u6570\u3042\u308a\u307e\u3059\uff08\u4ee5\u4e0b\u306b\u6570\u4f8b\u793a\u3057\u307e\u3059\u304c\u3001\u3082\u3063\u3068\u3042\u308b\u3067\u3057\u3087\u3046\uff09\u3002<\/p>\n<ul>\n<li><a href=\"https:\/\/console.cloud.google.com\/artifacts\/docker\/cloud-builders\/us\/gcr.io\/gcloud\"><code>gcr.io\/cloud-builders\/gcloud<\/code><\/a><\/li>\n<li><a href=\"https:\/\/console.cloud.google.com\/artifacts\/docker\/google.com:cloudsdktool\/us\/gcr.io\/google-cloud-cli\"><code>gcr.io\/google.com\/cloudsdktool\/google-cloud-cli<\/code><\/a><\/li>\n<li><a href=\"https:\/\/console.cloud.google.com\/artifacts\/docker\/google.com:cloudsdktool\/us\/gcr.io\/cloud-sdk\"><code>gcr.io\/google.com\/cloudsdktool\/cloud-sdk<\/code><\/a><\/li>\n<\/ul>\n<p>\u6700\u521d\u306e\u30a4\u30e1\u30fc\u30b8\u306f\u3001<a href=\"https:\/\/cloud.google.com\/build\/docs\/cloud-builders?hl=ja\">Cloud Build \u63d0\u4f9b\u306e\u30b5\u30dd\u30fc\u30c8\u3055\u308c\u3066\u3044\u308b\u30d3\u30eb\u30c0\u30fc \u30a4\u30e1\u30fc\u30b8<\/a>\u3067\u7d39\u4ecb\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u5b9f\u306f\u3001\u79c1\u304c\u30c6\u30b9\u30c8\u3057\u305f\u9650\u308a\u3067\u306f\u3001<code>gcr.io\/cloud-builders\/gcloud<\/code> \u306e\u30a4\u30e1\u30fc\u30b8\u306f\u3001\u300c\u30d3\u30eb\u30c9\u958b\u59cb\u6642\u70b9\u3067\u3001\u30d3\u30eb\u30c9\u3092\u5b9f\u884c\u3059\u308b\u4eee\u60f3\u30de\u30b7\u30f3\u3078\u306e\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u304c\u5b8c\u4e86\u3057\u3066\u3044\u308b\uff08\u30a4\u30e1\u30fc\u30b8\u304c\u5b58\u5728\u3057\u3066\u3044\u308b\uff09\u300d\u305f\u3081\u3001\u30a4\u30e1\u30fc\u30b8\u306e\u8ee2\u9001\u3092\u5f85\u305f\u305a\u306b\u3001\u3059\u3050\u306b\u30b3\u30de\u30f3\u30c9\u304c\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u3082\u3057\u3001<code>gcr.io\/google.com\/cloudsdktool\/google-cloud-cli<\/code> \u306e\u3088\u3046\u306b\u300c\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u304c\u5fc5\u8981\u306a\u30a4\u30e1\u30fc\u30b8\u300d\u3092\u4f7f\u3046\u3068\u3001\u30d3\u30eb\u30c9\u958b\u59cb\u6642\u70b9\u3067\u30a4\u30e1\u30fc\u30b8\u306e\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u304c\u59cb\u307e\u308a\u307e\u3059\u3002\u3053\u306e\u30a4\u30e1\u30fc\u30b8\u306f 1.2 GB \u7a0b\u5ea6\u3067\u3001\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u306b\u306f\u5927\u4f531\u5206\u7a0b\u5ea6\u304b\u304b\u308a\u307e\u3059\u3002<\/p>\n<p>\u9006\u306b\u8a00\u3046\u3068\u3001<code>gcloud<\/code> \u30b3\u30de\u30f3\u30c9\u304c\u4f7f\u3044\u305f\u3044\u3060\u3051\u3067\u3042\u308c\u3070\u3001\u30a4\u30e1\u30fc\u30b8\u3092\u5207\u308a\u66ff\u3048\u308b\u3060\u3051\u3067\u3001\u30d3\u30eb\u30c9\u6642\u9593\u304c\u77ed\u7e2e\u3055\u308c\u307e\u3059\u3002<\/p>\n<p><code>docker<\/code> \u3084 <code>git<\/code> \u30b3\u30de\u30f3\u30c9\u306b\u3064\u3044\u3066\u3082\u540c\u69d8\u3067\u3059\u3002<code>gcr.io\/cloud-builders\/docker<\/code>, <code>gcr.io\/cloud-builders\/git<\/code> \u3082\u3001\u8ffd\u52a0\u306e\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u6642\u9593\u3092\u767a\u751f\u3055\u305b\u305a\u306b\u3059\u3050\u306b\u4f7f\u3048\u308b\u30a4\u30e1\u30fc\u30b8\u3067\u3059\u3002<\/p>\n<h2>\u307e\u3068\u3081<\/h2>\n<p>Cloud Build \u306e\u30d3\u30eb\u30c9\u6642\u9593\u3092\u77ed\u7e2e\u3059\u308b\u305f\u3081\u306b\u306f\u3001<code>gcr.io\/cloud-builders\/gcloud<\/code> \u3092\u4f7f\u3046\u3060\u3051\u30671\u5206\u306e\u30d3\u30eb\u30c9\u6642\u9593\u304c\u77ed\u7e2e\u3067\u304d\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\n<code>docker<\/code> \u3084 <code>git<\/code> \u3092\u4f55\u304b\u306e\u30a4\u30e1\u30fc\u30b8\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u4f7f\u3063\u3066\u3044\u308b\u5834\u5408\u3082\u540c\u69d8\u306b\u3001Cloud Build \u63d0\u4f9b\u306e <code>docker<\/code> \u3084 <code>git<\/code> \u30a4\u30e1\u30fc\u30b8\u3067\u306e\u5229\u7528\u3092\u691c\u8a0e\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002\u305d\u308c\u305e\u308c1\u5206\u7a0b\u5ea6\u306e\u30d3\u30eb\u30c9\u6642\u9593\u304c\u77ed\u7e2e\u3055\u308c\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001Cloud Build \u3067\u4f7f\u3048\u308b\u300cCloud Build \u63d0\u4f9b\u306e\u30a4\u30e1\u30fc\u30b8\u300d\u306f\u4ed6\u306b\u3082\u3042\u308a\u307e\u3059\u3002\u3053\u308c\u3089\u3092\u77e5\u3063\u3066\u304a\u304f\u3068\u3001\u30d3\u30eb\u30c9\u6642\u9593\u306e\u77ed\u7e2e\u306b\u5f79\u7acb\u3064\u3067\u3057\u3087\u3046\u3002<\/p>\n<h2>\u53c2\u8003<\/h2>\n<ul>\n<li><a href=\"https:\/\/cloud.google.com\/build\/docs\/cloud-builders?hl=ja\">Cloud Build \u63d0\u4f9b\u306e\u30b5\u30dd\u30fc\u30c8\u3055\u308c\u3066\u3044\u308b\u30d3\u30eb\u30c0\u30fc \u30a4\u30e1\u30fc\u30b8<\/a> <a href=\"https:\/\/cloud.google.com\/build\/docs\/cloud-builders?hl=ja\">https:\/\/cloud.google.com\/build\/docs\/cloud-builders?hl=ja<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/GoogleCloudPlatform\/cloud-builders\">Google Cloud Build official builder images<\/a> GitHub <a href=\"https:\/\/github.com\/GoogleCloudPlatform\/cloud-builders\">https:\/\/github.com\/GoogleCloudPlatform\/cloud-builders<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/GoogleCloudPlatform\/cloud-sdk-docker\">Google Cloud CLI Docker<\/a> GitHub <a href=\"https:\/\/github.com\/GoogleCloudPlatform\/cloud-sdk-docker\">https:\/\/github.com\/GoogleCloudPlatform\/cloud-sdk-docker<\/a><\/li>\n<\/ul>\n<hr \/>\n<h1>Cloud Build Tips Part 1<\/h1>\n<h2>Summary<\/h2>\n<p>You can reduce your build time by one minute just by using <code>gcr.io\/cloud-builders\/gcloud<\/code>.<br \/>\nAdditionally, you can save time by learning about the other &quot;Supported builder images provided by Cloud Build.&quot;<\/p>\n<h2>Introduction<\/h2>\n<p>Hello everyone, are you using Cloud Build?<br \/>\nCloud Build is Google Cloud&#8217;s CI\/CD service. While it has many uses, it&#8217;s a powerful tool for building source code, creating container images, and deploying them.<\/p>\n<p>When it comes to &quot;operating&quot; Cloud Build, a common topic of discussion is &quot;time.&quot; Shortening your Cloud Build time has two main benefits:<\/p>\n<ol>\n<li>Reduces waiting time for developers<\/li>\n<li>Lowers build costs<\/li>\n<\/ol>\n<p>In this article, I&#8217;ll introduce a way to shorten only the build time without changing the actual contents of your build.<\/p>\n<h2>Details<\/h2>\n<p>Within your build process, you probably use a variety of tools. Among them, the gcloud command is likely used frequently to interact with Google Cloud resources.<\/p>\n<p>As it turns out, there are multiple Google Cloud images that provide the gcloud command (here are a few examples, but there are likely more).<\/p>\n<ul>\n<li><a href=\"https:\/\/console.cloud.google.com\/artifacts\/docker\/cloud-builders\/us\/gcr.io\/gcloud\"><code>gcr.io\/cloud-builders\/gcloud<\/code><\/a><\/li>\n<li><a href=\"https:\/\/console.cloud.google.com\/artifacts\/docker\/google.com:cloudsdktool\/us\/gcr.io\/google-cloud-cli\"><code>gcr.io\/google.com\/cloudsdktool\/google-cloud-cli<\/code><\/a><\/li>\n<li><a href=\"https:\/\/console.cloud.google.com\/artifacts\/docker\/google.com:cloudsdktool\/us\/gcr.io\/cloud-sdk\"><code>gcr.io\/google.com\/cloudsdktool\/cloud-sdk<\/code><\/a><\/li>\n<\/ul>\n<p>The first image is featured in the <a href=\"https:\/\/cloud.google.com\/build\/docs\/cloud-builders#supported_builder_images_provided_by\">&quot;Supported builder images provided by Cloud Build&quot;<\/a> documentation.<\/p>\n<p>Based on my testing, the <code>gcr.io\/cloud-builders\/gcloud<\/code> image is already downloaded to the virtual machine executing the build when the build starts (the image is already present). This allows commands to run immediately without waiting for the image to be pulled.<\/p>\n<p>On the other hand, if you use an image that needs to be downloaded, such as <code>gcr.io\/google.com\/cloudsdktool\/google-cloud-cli<\/code>, the image download will begin when the build starts. This image is about 1.2 GB, and the download takes approximately one minute.<\/p>\n<p>In other words, if all you need is the gcloud command, you can shorten your build time just by switching the image.<\/p>\n<p>The same principle applies to the <code>docker<\/code> and <code>git<\/code> commands. <code>gcr.io\/cloud-builders\/docker<\/code> and <code>gcr.io\/cloud-builders\/git<\/code> are also images that you can use immediately without incurring additional download time.<\/p>\n<h2>Conclusion<\/h2>\n<p>To shorten your Cloud Build time, you can potentially save one minute just by using <code>gcr.io\/cloud-builders\/gcloud<\/code>.<br \/>\nSimilarly, if you are currently installing <code>docker<\/code> or <code>git<\/code> into another image to use them, consider using the <code>docker<\/code> and <code>git<\/code> images provided by Cloud Build. You could potentially save about a minute of build time for each.<\/p>\n<p>There are other &quot;Cloud Build-provided images&quot; available as well. Familiarizing yourself with them can be very helpful for reducing your build times.<\/p>\n<h2>References<\/h2>\n<ul>\n<li><a href=\"https:\/\/cloud.google.com\/build\/docs\/cloud-builders\">Supported builder images provided by Cloud Build<\/a> <a href=\"https:\/\/cloud.google.com\/build\/docs\/cloud-builders\">https:\/\/cloud.google.com\/build\/docs\/cloud-builders<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/GoogleCloudPlatform\/cloud-builders\">Google Cloud Build official builder images<\/a> GitHub <a href=\"https:\/\/github.com\/GoogleCloudPlatform\/cloud-builders\">https:\/\/github.com\/GoogleCloudPlatform\/cloud-builders<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/GoogleCloudPlatform\/cloud-sdk-docker\">Google Cloud CLI Docker<\/a> GitHub <a href=\"https:\/\/github.com\/GoogleCloudPlatform\/cloud-sdk-docker\">https:\/\/github.com\/GoogleCloudPlatform\/cloud-sdk-docker<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Cloud Build \u306e\u30ef\u30b6 \u305d\u306e1 English follows Japanese. \u7d50\u8ad6 google-cloud-cli \u3084 cloud-sdk \u306e\u4ee3\u308f\u308a\u306b gcr.io\/cloud-builders\/gclo [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[27,13],"tags":[],"class_list":["post-587","post","type-post","status-publish","format-standard","hentry","category-cloud-build","category-google-cloud"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p4dIdP-9t","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/tako.nakano.net\/blog\/wp-json\/wp\/v2\/posts\/587","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tako.nakano.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tako.nakano.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tako.nakano.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tako.nakano.net\/blog\/wp-json\/wp\/v2\/comments?post=587"}],"version-history":[{"count":2,"href":"https:\/\/tako.nakano.net\/blog\/wp-json\/wp\/v2\/posts\/587\/revisions"}],"predecessor-version":[{"id":589,"href":"https:\/\/tako.nakano.net\/blog\/wp-json\/wp\/v2\/posts\/587\/revisions\/589"}],"wp:attachment":[{"href":"https:\/\/tako.nakano.net\/blog\/wp-json\/wp\/v2\/media?parent=587"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tako.nakano.net\/blog\/wp-json\/wp\/v2\/categories?post=587"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tako.nakano.net\/blog\/wp-json\/wp\/v2\/tags?post=587"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}