📘Deploy a FastAPI Application on Clouddley Apps

Learn how to deploy a FastAPI app on Clouddley Apps

With its intuitive and lightning-fast performance, FastAPI a Python-based web framework has gained popularity in the ever-evolving world of web development. In this guide, we will walk through how to simplify the deployment process of your FastAPI application on AWS using Clouddley Apps, a SaaS platform that allows you to choose and execute deployments on your preferred cloud provider.

Prerequisites

Create and Deploy the FastAPI application

Step 1

Using pip, install fastapi and uvicorn packages

  • Run this command:

pip install fastapi uvicorn[standard]

Step 2

Create a simple main.py file with the following contents:

main.py

from fastapi import FastAPI
import uvicorn

app = FastAPI()
@app.get("/")
def read_root():
    return {"Hello": "World"}


if __name__ == "__main__":
    uvicorn.run(app, host="0.0.0.0", port=3033)

Step 3

Test your application locally

  • Run the command

python main.py
  • Launch your web browser and visit localhost:3033

Step 4

Create your dependencies file

  • To create your requirements.txt file, run this command:

pip freeze >> requirements.txt

Step 5

Create a repository and push your code to GitHub

  • Run the commands below:

echo "# fastapi" >> README.md
git init
git add .
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/username/fastapi.git # add your repo URL here
git push -u origin main

Feel free to explore our source code here

Step 6

Create an App on Clouddley Apps

  • Log in to your Clouddley account and navigate to the Apps section.

  • Next, select Add app to begin creating a new application.

Step 7

Enable Git integration for your Clouddley Apps

  • Set up Git settings by choosing the Username/Organization, source code repository, and your preferred branch.

Step 8

Set up your cloud provider configuration

  • To set up the cloud provider, select your preferred Git connection.

Step 9

Configure your Application

  • To configure your application, proceed with these instructions:

    • Input your application's name.

    • Choose the project.

    • Set the application's port.

    • Choose the source code as the repository type.

    • Select the runtime; in this case, python3

    • Input the build command:

      pip install requirements.txt

    • Enter the start command:

      python main.py

Step 10

Configure your App settings

  • Networking: Configure how your service establishes connections with other applications, services, and resources. In Clouddley apps, you can choose between Public access and VPC connections.

Your service has the capability to transmit outgoing messages exclusively to public network endpoints. This is the default networking.

Step 11

Create your App

  • Click on Create App. This action will take you to your app dashboard, and after the app deployment is completed, the app status will change from deploying to running

  • Your application is now available via the URL provided on your app dashboard.

Your FastAPI application has been deployed successfully on Clouddley Apps!

Conclusion

Deploying a FastAPI application is straightforward, bringing your API to life quickly and efficiently. Following the steps outlined in this article enabled you to quickly deploy your FastAPI application on Clouddley Apps, helping you take full advantage of the speed and flexibility of this web framework. You can check out how to deploy other frameworks here.

Last updated