Google Professional Cloud Developer Question 389
Select 4Google Cloud PlatformYou are a developer tasked with creating a container image for your Python application using Google Cloud Build. The application requires several dependencies listed in a requirements.txt file. Which of the following steps are required to successfully build the container image using Cloud Build?
- A
Create a
Dockerfiledefining the application environment and build steps. - B
Write a
cloudbuild.yamlfile to define the build steps for Cloud Build. - C
Use the
gcloud builds submitcommand to trigger the Cloud Build process. - D
Add the
requirements.txtfile to the.gitignorefile to exclude it from the build context. - E
Ensure that the
Dockerfileandrequirements.txtfile are in the same directory.
Show answer and explanation
Correct answers: A, B, C, E
Explanation
To successfully build a container image using Cloud Build, you need to define the application environment using a Dockerfile, specify the build steps in a cloudbuild.yaml file, and submit the build using the gcloud builds submit command. Ensuring that all necessary files such as requirements.txt are included in the same directory is also essential for a successful build. Excluding critical files like requirements.txt from the build context will result in failures during the build process.
- A. Correct.
Correct. A
Dockerfileis required to define the environment and instructions for building the container image. - B. Correct.
Correct. The
cloudbuild.yamlfile specifies the steps Cloud Build will perform during the build process. - C. Correct.
Correct. The
gcloud builds submitcommand is used to submit the build to Google Cloud Build. - D. Incorrect.
Incorrect. Excluding the
requirements.txtfile from the build context will cause the build to fail because the dependencies cannot be installed. - E. Correct.
Correct. Placing the
Dockerfileandrequirements.txtfile in the same directory ensures that the build context includes all necessary files.