This repository includes a very simple Python Flask web site, made for demonstration purposes only.
This project has devcontainer support, so you can open it in Github Codespaces or local VS Code with the Dev Containers extension.
Steps for running the server:
-
(Optional) If you're unable to open the devcontainer, create a Python virtual environment and activate that.
-
Install the requirements:
python3 -m pip install -r requirements-dev.txt
-
Run the local server: (or use VS Code "Run" button and select "Run server")
python3 -m flask --debug --app src/app:app run --port 5000
-
Click 'http://127.0.0.1:5000' in the terminal, which should open the website in a new tab
-
Confirm the photos load on the index page and click "Order Print" to see the order page.
You can also run this app locally with Docker, thanks to the Dockerfile
.
You need to either have Docker Desktop installed or have this open in Github Codespaces for these commands to work.
-
Build the image:
docker build --tag flask-app src/
-
Run the image:
docker run --publish 5000:5000 flask-app
This repo is set up for deployment on Azure Container Apps using the configuration files in the infra
folder.
Steps for deployment:
-
Sign up for a free Azure account
-
Install the Azure Dev CLI. (If you opened this repository in a devcontainer, that part will be done for you.)
-
Initialize a new
azd
environment:azd init
It will prompt you to provide a name (like "flask-app") that will later be used in the name of the deployed resources.
-
Provision and deploy all the resources:
azd up
It will prompt you to login, pick a subscription, and provide a location (like "eastus"). Then it will provision the resources in your account and deploy the latest code.
-
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
These are only provided as an example, as of Feb-2023. The PostgreSQL server has an hourly cost, so if you are not actively using the app, remember to run azd down
or delete the resource group to avoid unnecessary costs.
- Azure CDN - Standard tier, $0.081 per GB for first 10 TB per month. Pricing
- Azure Container App - Consumption tier with 0.5 CPU, 1GiB memory/storage Pricing is based on resource allocation, and each month allows for a certain amount of free usage, ~$2/month. Pricing
- Azure Container Registry - Basic tier. $0.167/day, ~$5/month. Pricing
- Key Vault - Standard tier. $0.04/10,000 transactions. Only a few transactions are used on each deploy. Pricing
If you're working with this project and running into issues, please post in Discussions.