QuestionQ57

VerifiedBuilding and implementing CI/CD pipelines, including continuous testing, for application, infrastructure, and machine learning workloads

Your team has an application built using a Dockerfile. Cloud Build performs the build, and the resulting artifacts are stored in Artifact Registry. Your team reports that builds are slow. You need to improve build speed while following Google-recommended practices. What should you do?

Explanation

Google recommends using --cache-from pointing to a previously built image in your registry (Artifact Registry) so Cloud Build reuses cached layers. Because --cache-from rebuilds every layer from the first changed layer to the end of the build, you must place the most frequently modified files in the LATER stages of the Dockerfile, keeping stable dependencies in earlier, cacheable layers. Option B (earlier stages) invalidates the cache on every code change and defeats the optimization. Caching layers to Cloud Storage (C/D) is not the Google-recommended Docker layer-cache mechanism for this scenario.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!