This sample project demonstrates how to deploy FastAPI with PostgreSQL with Defang.
- Download Defang CLI
- (optional) If you are using Defang BYOC, make sure you have properly authenticated your AWS account.
To run the development container(s) locally, do:
docker compose -f compose.dev.yaml up --buildOr to run the production container(s) locally, do:
POSTGRES_PASSWORD=postgres docker compose up --buildFor this sample, you will need to provide the following configuration:
Note that if you are using the 1-click deploy option, you can set these values as secrets in your GitHub repository and the action will automatically deploy them for you.
defang config set POSTGRES_PASSWORDNote
Download Defang CLI
Deploy your application to the Defang Playground by opening up your terminal and typing:
defang compose upIf you want to deploy to your own cloud account, you can use Defang BYOC:
- Authenticate your AWS account, and check that you have properly set your environment variables like
AWS_PROFILE,AWS_REGION,AWS_ACCESS_KEY_ID, andAWS_SECRET_ACCESS_KEY. - Run in a terminal that has access to your AWS environment variables:
defang --provider=aws compose up
Title: FastAPI & PostgreSQL
Short Description: A sample project with FastAPI and PostgreSQL.
Tags: FastAPI, PostgreSQL, Python, SQL
Languages: python