Google Professional Cloud Developer Question 337
Single answerGoogle Cloud PlatformYou are developing a Node.js application and want to deploy it to Google Cloud Run directly from your source code repository hosted on GitHub. You also want the deployment process to automatically build your container image using Cloud Build. Which method should you use to achieve this?
- A
Use the 'gcloud run deploy' command with the '--source' flag.
- B
Create a Dockerfile, build the image locally, push it to Container Registry, and then deploy it to Cloud Run.
- C
Set up a Cloud Build trigger connected to your GitHub repository and configure it to deploy the application to Cloud Run.
- D
Manually create a container image using Docker, push it to Artifact Registry, and deploy it to Cloud Run.
Show answer and explanation
Correct answer: A
Explanation
To deploy a Node.js application to Cloud Run directly from source code and automatically build the container image using Cloud Build, the recommended approach is to use the 'gcloud run deploy' command with the '--source' flag. This simplifies the process by automating the container build and deployment in a single step, eliminating the need for manual image creation or trigger configurations.
- A. Correct.
This is correct. The '--source' flag of the 'gcloud run deploy' command allows you to deploy directly from source code. It uses Cloud Build to automatically build the container image during the deployment process.
- B. Incorrect.
This is incorrect. While this method works, it involves manual steps that are not necessary since 'gcloud run deploy --source' can automate this process for you.
- C. Incorrect.
This is incorrect. While Cloud Build triggers can automate builds and deployments, setting up triggers is more complex and unnecessary for a simple deployment directly from source.
- D. Incorrect.
This is incorrect. Manually creating and pushing an image to Artifact Registry is unnecessary when deploying directly from source using Cloud Build.