nerdexam
Google

PROFESSIONAL-CLOUD-DEVELOPER · Question #157

You are configuring a continuous integration pipeline using Cloud Build to automate the deployment of new container images to Google Kubernetes Engine (GKE). The pipeline builds the application from i

The correct answer is A. Select a virtual machine (VM) size with higher CPU for Cloud Build runs. C. Cache the Docker image for subsequent builds using the -- cache-from argument in your build. Two changes reduce Cloud Build time: (A) Selecting a higher-CPU machine type for Cloud Build runs allows compilation, pip installs, and Docker layer operations to execute faster, directly reducing wall-clock build time. (C) Using --cache-from in the Docker build command instructs

Building and deploying applications

Question

You are configuring a continuous integration pipeline using Cloud Build to automate the deployment of new container images to Google Kubernetes Engine (GKE). The pipeline builds the application from its source code, runs unit and integration tests in separate steps, and pushes the container to Container Registry. The application runs on a Python web server. The Dockerfile is as follows:

FROM python:3.7-alpine COPY . /app WORKDIR /app RUN pip install -r requirements.txt CMD [ "gunicorn", "-w 4", "main:app" ] You notice that Cloud Build runs are taking longer than expected to complete. You want to decrease the build time. What should you do? (Choose two.)

Options

  • ASelect a virtual machine (VM) size with higher CPU for Cloud Build runs.
  • BDeploy a Container Registry on a Compute Engine VM in a VPC, and use it to store the final
  • CCache the Docker image for subsequent builds using the -- cache-from argument in your build
  • DChange the base image in the Dockerfile to ubuntu:latest, and install Python 3.7 using a package
  • EStore application source code on Cloud Storage, and configure the pipeline to use gsutil to

How the community answered

(21 responses)
  • A
    62% (13)
  • B
    5% (1)
  • D
    24% (5)
  • E
    10% (2)

Explanation

Two changes reduce Cloud Build time: (A) Selecting a higher-CPU machine type for Cloud Build runs allows compilation, pip installs, and Docker layer operations to execute faster, directly reducing wall-clock build time. (C) Using --cache-from in the Docker build command instructs Docker to reuse layers from a previously built and pushed image. Since the requirements.txt and pip install layer changes infrequently, caching it avoids reinstalling all Python packages on every build - often the slowest step. Option D is wrong because ubuntu:latest is a much larger base image than python:3.7-alpine, which would increase build and pull times. Option B adds unnecessary infrastructure complexity. Option E (Cloud Storage for source) does not improve build speed meaningfully.

Topics

#Cloud Build#CI/CD#Docker#Build Optimization

Community Discussion

No community discussion yet for this question.

Full PROFESSIONAL-CLOUD-DEVELOPER Practice