FastAPI#
To deploy a FastAPI application in Ploomber Cloud you need:
A Ploomber Cloud account
A
Dockerfile
Your code
Dockerfile
#
You need to provide a Dockerfile
, you can use this template to get started. The template contains the minimal steps needed for a deployment but you need to modify so it installs any required dependencies and copies your code into the Docker image.
FROM python:3.11
# assumes app.py contains your fastapi app
COPY app.py app.py
# install dependencies
RUN pip install fastapi uvicorn
# this configuration is needed for your app to work, do not change it
ENTRYPOINT ["uvicorn", "app:app", "--host=0.0.0.0", "--port=80"]
Testing locally#
To test your app, you can use docker
locally:
# build the docker image
docker build . -t fastapi
# run it
docker run -p 5000:80 fastapi
Now, open http://0.0.0.0:5000/ to see your app.
Deploy#
Once you have all your files, create a zip file.
To deploy a FastAPI app from the deployment menu, follow these instructions:
Tip
To ensure your app doesn’t break on re-deployments, pin your dependencies.
Features#
Ploomber Cloud supports many features to help you build FastAPI applications quickly!
Integration with GitHub
Safely store secrets such as API keys
Add password protection to your app
Usage analytics such as unique visitors, total requests, etc.
Spin up larger resources (CPUs and RAM)
Spin up GPUs
Add custom domains or subdomains to your application
Task queues to scale applications to more users
Examples#
A basic FastAPI app.
An API to index a GitHub repo and then ask questions.
An API to ask questions about an image.