What We’re Deploying
FastAPI is a relatively new API framework for Python apps, which is built from the ground up for performance and reliability. The interesting thing about FastAPI is that it supports async functions natively (so you get the best of asynchronous programming, but with Python), and it is built on Pythonic type hints - which helps you ship faster without getting bogged down by the intricacies of dynamic types. If you’re looking at quickly rolling out your app and have some familiarity with Python, FastAPI is a great way to quickly get started with rolling out your backend components. We’re going to deploy a sample FastAPI server - but that doesn’t mean you’re restricted to FastAPI. You’re free to use any and all Python web frameworks (the Flask web framework is also common among Porter users). This app’s a very basic app with a single endpoint - ‘/’ to demonstrate how you can push out a public-facing app on Porter Cloud with a public facing domain and TLS. The idea here is to show you how a basic app can be quickly deployed on Porter Cloud, allowing you to then use the same flow for deploying your code. You can find the repository for this sample app here: https://github.com/porter-dev/fastapi-getting-started. Feel free to fork/clone it, or bring your own.Deploying Your App
Deploying an app from a GitHub repository on Porter involves - broadly - the following steps:- Creating a new app on Porter where you specify the repository, the branch, any build settings, as well as what you’d like to run.
- Building your app and deploying it (automatically handled by Porter so you don’t have to worry about Continuous Integration and Continuous Deployment).
Creating an App and Connecting Your GitHub Repository
On the Porter Cloud dashboard, select ‘Create a new application’, which opens the following screen:
If you signed up for Porter Cloud using an email address instead of a Github account, you can easily connect your Github account to Porter by clicking on the profile icon on the top right corner of the dashboard, selecting ‘Account settings’, and adding your Github account.
Configuration of Build Settings
Porter has the ability to automatically detect what language your app is written in and select an appropriate buildpack that can be used to package your app for eventual deployment automatically. Once you’ve selected the branch you wish to use, Porter will display the following screen:
Configuration of services
At this point, taking a quick look at applications and services is a good idea. An application on Porter is a group of services where each service shares the same build and the same environment variables. If your app consists of a single repository with separate modules for, say, an API, a frontend, and a background worker, then you’d deploy a single application on Porter with three separate services. Porter supports three kinds of services: ‘web’, ‘worker’, and ‘job’ services. Let’s add a single ‘web’ service for our app:
Configure Your Service
Now that we’ve defined a single web service in the previous steps, it’s time to tell Porter how it runs. That means specifying what command to run for this service, what CPU/RAM levels to allocate, and how it will be accessed publicly.


If your app listens on ‘localhost’ or ‘127.0.0.1’, Porter won’t be able to forward incoming connections and requests to your app. To that end, please ensure your app is configured to listen on ‘0.0.0.0’ instead.
Review and Merge Porter’s PR
Hitting ‘Deploy’ will show you the contents of a GitHub Action workflow that Porter would use to build and deploy your app:





Accessing Your App
After completing the previous steps, our FastAPI app’s now live on Porter Cloud. The Porter-generated unique URL or domain name is now visible on the dashboard under your app’s name. Let’s test it:



Exploring Further
We’ve seen how you can deploy FastAPI on Porter. Here are a few pointers to help you dive further into configuring/tuning your app without having to manage your infrastructure/DevOps:- Adding your own domain.
- Adding environment variables and groups (environment groups are only available when hosting on Porter Standard).
- Scaling your app.
- Ensuring your app’s never offline (we’ll renew and manage the SSL certificate for you).