Coder Social home page Coder Social logo

aca-flask-media's Introduction

This repository includes a very simple Python Flask web site, made for demonstration purposes only.

Local development

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:

  1. (Optional) If you're unable to open the devcontainer, create a Python virtual environment and activate that.

  2. Install the requirements:

    python3 -m pip install -r requirements-dev.txt
  3. 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
  4. Click 'http://127.0.0.1:5000' in the terminal, which should open the website in a new tab

  5. Confirm the photos load on the index page and click "Order Print" to see the order page.

Local development with Docker

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.

  1. Build the image:

    docker build --tag flask-app src/
  2. Run the image:

    docker run --publish 5000:5000 flask-app

Deployment

This repo is set up for deployment on Azure Container Apps using the configuration files in the infra folder.

Diagram of architecture using Azure Container Apps, Azure Container Registry and an Azure CDN in front

Steps for deployment:

  1. Sign up for a free Azure account

  2. Install the Azure Dev CLI. (If you opened this repository in a devcontainer, that part will be done for you.)

  3. 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.

  4. 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.

  5. 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! ๐ŸŽ‰

  6. When you've made any changes to the app code, you can just run:

    azd deploy

CI/CD pipeline

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

Costs

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

Getting help

If you're working with this project and running into issues, please post in Discussions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.