A Developer’s Guide to Building Serverless Applications on the Cloud — Part 1 (Deployment)

Serverless Compute on Google Cloud

In this series, I’ll discuss few topics crucial to building serverless applications while using Google Cloud, they would span across deployment, CI/CD, tooling, backend-as-a-service and more.

In this article, I will discuss how Developers at DevShopZ easily moved from local development to the Cloud. This covers simple functions, web-based application, and containerized applications including code samples.

If you are new to Serverless, check out this post

DevShopZ recently started a new project for a client, her engineers had made lots of progress in building the project, however, the project manager wants it deployed so the client can have an idea of what he’s getting and also provide feedback to the team.

Developers at DevShopZ started the project by building simple API endpoints, then moved on to integrating the frontend and other tools such as Docker. We shall see how the deployment was done at each stage of the project.

Before you begin:

  • The developers made use of Google Cloud account for free, details here
  • They created a new GCP project, you can also do the same here
  • The developers used the Google Cloud Shell terminal to execute the deployment commands.

Deploying Functions

The Engineers built the first simple endpoint which is a Python function that returns a JSON message. Tip: You could use any language of choice

Functions Code

The endpoint function was deployed to Cloud Functions

Google Cloud Functions is a lightweight compute solution for developers to create single-purpose, stand-alone functions that respond to cloud events without the need to manage a server or runtime environment.

gcloud functions deploy hello_world --runtime python37 --trigger-http

Execute the command above on Cloud Shell after cloning the sample codes from the Gist or setting up your own codes.

Deployed Function

Deploying Web Applications (without containers)

The project has grown into a full Web Application built using the Flask Web framework and now includes static files.
Tip: You could use any framework of choice

Web App Codes

The Web Application was deployed to App Engine

App Engine is a fully managed, serverless platform for developing and hosting web applications at scale. You can choose from several popular languages, libraries, and frameworks to develop your apps, then let App Engine take care of provisioning servers and scaling your app instances based on demand.

gcloud app deploy

Execute the command above on Cloud Shell after cloning the sample codes from the Gist or setting up your own codes

Deployed Web Application

Deploying containers

The team decided to adopt containerization technologies by Dockerizing the existing Web Application. The source codes were updated to include a Dockerfile that was used to build the container image.

Web App Container Codes

There are multiple options for deploying container images on Google Cloud, see this short video

Cloud Run is a managed compute platform that automatically deploys and scales your stateless containers. Cloud Run is serverless; it abstracts away all infrastructure management, so you can focus on what matters most — building great applications.

gcloud builds submit --config cloudbuild.yaml

The cloudbuild.yaml file is a configuration file for Google Cloud Build which contains two steps:
one to build the container image & upload to Google Container Registry; step two then deploys the image to Cloud Run.

Execute the command above on Cloud Shell after cloning the sample codes from the Gist or setting up your own codes

Deployed Containerized Web App

Useful Links

Stay tuned for the next article where I will discuss a more exciting serverless topic.




A collection of technical articles and blogs published or curated by Google Cloud Developer Advocates. The views expressed are those of the authors and don't necessarily reflect those of Google.

Recommended from Medium

Change Flutter app theme according to the system theme mode

Different Breeds of Developers

MWeb Brings Skills to the Genre

Tooltips with CSS

Initial setup


Java Concurrency: Executors

Effective Java ch3

VREG Click: adjustable power supply with Arduino Uno

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


Software / DevOps Engineer | Google Developer Expert for Cloud | https://www.codementor.io/@timtech4u

More from Medium

Google Cloud SFTP and FTP

google sftp ftp

Google Cloud Platform — Technology Nuggets — January 16–31, 2022 Edition

Understanding Google Cloud IAM concepts with stick figures

Composite GitHub Actions for Deploying GCP resources to multiple projects