Deploy a python app from source code using Cloud Run

By Google Cloud Tech

TechnologyAIStartup
Share:

Key Concepts:

  • Cloud Run
  • Deploy From Source Code
  • gcloud run deploy command
  • Containerization
  • Cloud Build
  • Artifact Registry
  • Revisions
  • Unauthenticated Invocations

Deploying Source Code to Cloud Run

The video demonstrates how to deploy source code directly to Google Cloud Run using the gcloud run deploy command, simplifying the deployment process for application developers. This method eliminates the need for manual Dockerfile creation and container image building.

1. Setting Up the Environment

  • The demo uses the Cloud Shell Editor, pre-configured with a folder containing the source code for a "Hello World" Flask Python web application.
  • The folder includes main.py (the application code) and requirements.txt (specifying dependencies).

2. Executing the gcloud run deploy Command

  • The core command is gcloud run deploy.
  • The command prompts the user for required information:
    • Source Code Location: Defaults to the current directory.
    • Service Name: The user specifies a name (e.g., hello-cloud-run).
    • Region: The user selects a region for deployment (e.g., us-west2).
    • Unauthenticated Invocations: The user is asked whether to allow public access (chooses "yes" for a public website).

3. Deployment Process

  • The source code is zipped and uploaded to a Cloud Storage bucket.
  • Cloud Build is triggered to build the container image.
  • The video provides a link to the Cloud Build logs for monitoring progress.
  • The build process involves:
    • Building the container image.
    • Pushing the image to Artifact Registry.
    • Creating a new service in Cloud Run.
  • The build process took approximately 1 minute and 30 seconds in the demo.

4. Verification and Access

  • Upon successful deployment, the service and revision are deployed, serving 100% of traffic.
  • The video demonstrates accessing the deployed application via the service URL, which displays "Hello World!".

5. Examining the Deployed Revision

  • The video navigates to the Cloud Run Cloud Console page to inspect the deployed revision.
  • The Revisions tab shows that 100% of traffic is automatically migrated to the newest revision.
  • The full path to the container image in Artifact Registry is displayed.

6. Artifact Registry Location

  • The container image is stored in Artifact Registry, specifically in the us-west2 region within a repository named Cloud Run Source Deploy.

7. Recap and Key Takeaways

  • The key command for deploying applications to Cloud Run from source code is gcloud run deploy.
  • This method provides a fast and efficient way to get applications running on Google Cloud without managing Dockerfiles or container image builds manually.
  • The video encourages viewers to explore the quickstarts in the Google Cloud documentation for further guidance.

Notable Quotes:

  • "This Deploy From Source Code feature takes your application code, whether it's Node, Python, Java, Go, .NET, Ruby, or PHP and deploys it to Cloud Run without you having to create a Dockerfile or build the container image yourself beforehand."
  • "The only command you need to know to get started running your apps on Cloud Run is gcloud run deploy."

Technical Terms and Concepts:

  • Cloud Run: A managed compute platform that enables you to run stateless containers invocable via HTTP requests.
  • Deploy From Source Code: A Cloud Run feature that automatically builds and deploys container images from source code.
  • gcloud run deploy: The command-line tool used to deploy applications to Cloud Run.
  • Containerization: Packaging an application and its dependencies into a container image.
  • Cloud Build: A service that executes your builds on Google Cloud Platform.
  • Artifact Registry: A service for storing, managing, and securing container images and other artifacts.
  • Revisions: Immutable snapshots of a Cloud Run service's configuration and code.
  • Unauthenticated Invocations: Allowing public access to a Cloud Run service without requiring authentication.

Logical Connections:

The video follows a logical progression: introduction of the problem (managing infrastructure), presentation of the solution (Deploy From Source Code), demonstration of the solution (using gcloud run deploy), verification of the deployment, and a recap of the key takeaways.

Synthesis/Conclusion:

The video effectively demonstrates the ease and speed of deploying applications to Google Cloud Run using the Deploy From Source Code feature and the gcloud run deploy command. By abstracting away the complexities of Dockerfile creation and container image building, developers can focus on writing code and quickly deploying their applications. The integration with Cloud Build and Artifact Registry ensures a streamlined and automated deployment process.

Chat with this Video

AI-Powered

Hi! I can answer questions about this video "Deploy a python app from source code using Cloud Run". What would you like to know?

Chat is based on the transcript of this video and may not be 100% accurate.

Related Videos

Ready to summarize another video?

Summarize YouTube Video