This project deploys a web application for a space travel agency using FastAPI. The application can be deployed to Azure with Azure Container Apps using the Azure Developer CLI.
This project has Dev Container support, so it will be be setup automatically if you open it in Github Codespaces or in local VS Code with the Dev Containers extension.
If you're not using one of those options for opening the project, then you'll need to:
-
Create a Python virtual environment and activate it.
-
Install production requirements:
python3 -m pip install -r src/requirements.txt
-
Install the app as an editable package:
python3 -m pip install -e src
-
Apply database migrations and seed initial data:
python3 src/fastapi_app/seed_data.py
Run gunicorn on the app:
python3 -m gunicorn fastapi_app:app -c src/gunicorn.conf.py
-
Install the development requirements:
python3 -m pip install -r requirements-dev.in playwright install --with-deps
-
Run the tests:
python3 -m pytest
This repo is set up for deployment on Azure via Azure Container Apps.
Steps for deployment:
-
Sign up for a free Azure account and create an Azure Subscription.
-
Install the Azure Developer CLI. (If you open this repository in Codespaces or with the VS Code Dev Containers extension, that part will be done for you.)
-
Login to Azure:
azd auth login
-
Provision and deploy all the resources:
azd up
It will prompt you to provide an
azd
environment name (like "myapp"), select a subscription from your Azure account, and select a location (like "eastus"). Then it will provision the resources in your account and deploy the latest code. If you get an error with deployment, changing the location can help, as there may be availability constraints for some of the resources. -
When
azd
has finished deploying, you'll see an endpoint URI in the command output. Visit that URI, and you should see the front page of the app! 🎉 -
When you've made any changes to the app code, you can just run:
azd deploy
This project includes a Github workflow for deploying the resources to Azure on every push to main. That workflow requires several Azure-related authentication secrets to be stored as Github action secrets. To set that up, run:
azd pipeline config