Deploy a Dockerized FastAPI App to Google Cloud Platform

A short guide to deploying a Dockerized Python app to Google Cloud Platform using Cloud Run and a SQL instance.

In this article, we will discuss FastAPI and Docker. Then we will use these technologies to create and deploy a data API on GCP quickly and easily.

Here is the GitHub repository for this project.

edkrueger/sars-fastapi

For more information on the app code and structure, check out this article.

Building a Data API with FastAPI and SQLAlchemy

We use pipenv for this project, but you don’t have to.

What is FastAPI?

”FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.6+ based on standard Python type hints.” — — — FastAPI Documentation

FastAPI is an API based on Pydanticand Starlette. FastAPI uses Pydantic to define a schema and validate data. Starlette isa lightweight ASGI framework/toolkit, which is ideal for building high-performance async services.

Other python microservice frameworks don’t integrate with SQLAlchemy easily. For example, It is common to use Flask with a package called Flask-SQLAlchemy. There is no FastAPI-SQLALchemly because FastAPI integrates well with vanilla SQLAlchemy! Additionally, FastAPI integrates well with many packages, including many ORMs and allows you to use most relational databases.

#cloud #fastapi #google cloud platform

Deploy a Dockerized FastAPI App to Google Cloud Platform