Google Professional Cloud Developer Question 387
Select 3Google Cloud PlatformYou are tasked with building a container image for a Python-based web application using Google Cloud Build. The application requires dependencies listed in a requirements.txt file. Which of the following steps are required to correctly build the image using Cloud Build?
- A
Create a
cloudbuild.yamlfile specifying the build steps to install dependencies and package the application. - B
Ensure that the Dockerfile is included in the application's root directory.
- C
Execute the
gcloud builds submitcommand, specifying the--tagflag to define the image name. - D
Manually install Python dependencies on your local machine before running the build process.
- E
Use a prebuilt container image in Cloud Build without writing a Dockerfile or
cloudbuild.yamlfile.
Show answer and explanation
Correct answers: A, B, C
Explanation
To build a container image for a Python-based application using Cloud Build, you need to define the build steps in a cloudbuild.yaml file and include a Dockerfile for the build process. The gcloud builds submit command is then used to trigger the automated build. Manually installing dependencies or relying solely on prebuilt images is not suitable for this scenario, as the goal is to create a custom image for the application.
- A. Correct.
Correct: A
cloudbuild.yamlfile is required to define the steps for building the container image, such as installing dependencies and packaging the application. - B. Correct.
Correct: A Dockerfile is necessary for defining how the container image is built, including installing dependencies and setting up the application runtime.
- C. Correct.
Correct: The
gcloud builds submitcommand is used to trigger the build process in Cloud Build. The--tagflag ensures the built image is tagged appropriately. - D. Incorrect.
Incorrect: Dependencies should not be manually installed on the local machine as the build process should be automated and self-contained.
- E. Incorrect.
Incorrect: While prebuilt images can be used, they are not appropriate for this scenario as you must create a custom image for the Python application.