GCP: Build and Deploy with Cloud Run and App Engine

vaasu1234

Srinivas Pasupuleti

Posted on December 23, 2023

GCP: Build and Deploy with Cloud Run and App Engine

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
Enter fullscreen mode Exit fullscreen mode

Cloud Run:

$ 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
Enter fullscreen mode Exit fullscreen mode

App Engine:

Python

Requirements:

  • Use Python3 version > 3.10
$ gcloud app deploy

$ gcloud app browse

$ gcloud app describe

$ gcloud app logs tail -s default
Enter fullscreen mode Exit fullscreen mode

Java:

Requirements

Environment

$ export CLOUDSDK_PYTHON="/usr/bin/python3"

$ export JAVA_HOME="/usr/libexec/java_home"
Enter fullscreen mode Exit fullscreen mode

Commands to Run and Deploy

$ ./mvnw -DskipTests spring-boot:run

$ ./mvnw -DskipTests package appengine:deploy
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
vaasu1234
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