GCP: Build and Deploy with Cloud Run and App Engine
Srinivas Pasupuleti
Posted on December 23, 2023
Cloud Run and App Engine are Platform as a Service (PaaS) products that enables you to deploy your microservices or web applications. The major difference between them is that Cloud Run uses container images to be deployed so that they are platform agnostic where as App engine is a standard deployment. Both PaaS solutions offer automatic resource provisioning, scalability, rate controls and traffic monitoring.
Setting up gCloud:
//Authorize with your gcp account and ensure right project is selected
$ gcloud init
//list all the accounts
$ gcloud auth list
$ gcloud config list project
Cloud Run:
- Code Lab: https://codelabs.developers.google.com/codelabs/cloud-run-deploy#0
- Github Src: https://github.com/vaasu1234/gcp/tree/master/cloud-run-demo
$ git clone https://github.com/vaasu1234/gcp.git
$ cd cloud-run-demo
//setup script expects that the commands are run on cloud shell. If running locally execute each step in setup script manually (npm install)
$ ./setup.sh
$ gcloud services enable cloudbuild.googleapis.com
$ gcloud builds submit --tag gcr.io/${GOOGLE_CLOUD_PROJECT}/monolith:1.0.0 .
$ gcloud run deploy --image=gcr.io/${GOOGLE_CLOUD_PROJECT}/monolith:1.0.0 --platform managed
$ gcloud run services describe monolith --platform managed
$ gcloud run services list
App Engine:
Python
- [Simple Code Lab] https://codelabs.developers.google.com/codelabs/cloud-app-engine-python3
- [Advanced Code Lab] https://cloud.google.com/appengine/docs/standard/python3/building-app
- [GitHub Src] https://github.com/vaasu1234/gcp/tree/master/helloworld
Requirements:
- Use Python3 version > 3.10
$ gcloud app deploy
$ gcloud app browse
$ gcloud app describe
$ gcloud app logs tail -s default
Java:
- Code Lab: https://cloud.google.com/appengine/docs/standard/java-gen2/building-app
- GitHub Src: https://github.com/vaasu1234/gcp/tree/master/springboot
Requirements
- Get Springboot sample app: https://start.spring.io/
- Select Maven, Add Web Dependency
- Install Java 17
- IntelliJ IDE
Environment
$ export CLOUDSDK_PYTHON="/usr/bin/python3"
$ export JAVA_HOME="/usr/libexec/java_home"
Commands to Run and Deploy
$ ./mvnw -DskipTests spring-boot:run
$ ./mvnw -DskipTests package appengine:deploy
💖 💪 🙅 🚩
Srinivas Pasupuleti
Posted on December 23, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
githubcopilot AI Innovations at Microsoft Ignite 2024 What You Need to Know (Part 2)
November 29, 2024