{"id":13289023,"url":"https://github.com/pamelafox/simple-fastapi-container","last_synced_at":"2025-04-19T15:48:46.623Z","repository":{"id":160107318,"uuid":"614114437","full_name":"pamelafox/simple-fastapi-container","owner":"pamelafox","description":"A simple FastAPI app that is containerized and designed for development on Azure Container Apps.","archived":false,"fork":false,"pushed_at":"2025-03-17T20:07:00.000Z","size":202,"stargazers_count":23,"open_issues_count":3,"forks_count":13,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-16T09:22:54.680Z","etag":null,"topics":["azd-templates","azure","azure-container-apps","fastapi","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pamelafox.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-14T23:22:52.000Z","updated_at":"2025-03-17T20:07:04.000Z","dependencies_parsed_at":"2024-05-06T15:54:23.864Z","dependency_job_id":"d6ca3fe3-5f68-49cb-ae24-55cfa024db78","html_url":"https://github.com/pamelafox/simple-fastapi-container","commit_stats":null,"previous_names":[],"tags_count":0,"template":true,"template_full_name":"pamelafox/simple-flask-api-container","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pamelafox%2Fsimple-fastapi-container","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pamelafox%2Fsimple-fastapi-container/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pamelafox%2Fsimple-fastapi-container/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pamelafox%2Fsimple-fastapi-container/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pamelafox","download_url":"https://codeload.github.com/pamelafox/simple-fastapi-container/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249730641,"owners_count":21317327,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["azd-templates","azure","azure-container-apps","fastapi","python"],"created_at":"2024-07-29T17:00:18.105Z","updated_at":"2025-04-19T15:48:46.602Z","avatar_url":"https://github.com/pamelafox.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple FastAPI container\n\nThis repository includes a simple Python FastAPI app with a single route that returns JSON.\nYou can use this project as a starting point for your own APIs.\n\nThe repository is designed for use with [Docker containers](https://www.docker.com/), both for local development and deployment, and includes infrastructure files for deployment to [Azure Container Apps](https://learn.microsoft.com/azure/container-apps/overview). 🐳\n\nThe code istested with [pytest](https://docs.pytest.org/en/7.2.x/),\nlinted with [ruff](https://github.com/charliermarsh/ruff), and formatted with [black](https://black.readthedocs.io/en/stable/).\nCode quality issues are all checked with both [pre-commit](https://pre-commit.com/) and Github actions.\n\n## Opening the project\n\nThis project has [Dev Container support](https://code.visualstudio.com/docs/devcontainers/containers), so it will be be setup automatically if you open it in Github Codespaces or in local VS Code with the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers).\n\nIf you're not using one of those options for opening the project, then you'll need to:\n\n1. Create a [Python virtual environment](https://docs.python.org/3/tutorial/venv.html#creating-virtual-environments) and activate it.\n\n2. Install the requirements:\n\n    ```shell\n    python3 -m pip install -r requirements-dev.txt\n    ```\n\n3. Install the pre-commit hooks:\n\n    ```shell\n    pre-commit install\n    ```\n\n## Local development\n\n1. Run the local server:\n\n    ```shell\n    fastapi dev src/api/main.py\n    ```\n\n2. Click 'http://127.0.0.1:8000' in the terminal, which should open a new tab in the browser.\n\n3. Try the API at '/generate_name' and try passing in a parameter at the end of the URL, like '/generate_name?starts_with=N'.\n\n### Local development with Docker\n\nYou can also run this app with Docker, thanks to the `Dockerfile`.\n\nYou need to either have Docker Desktop installed or have this open in Github Codespaces for these commands to work. ⚠️ If you're on an Apple M1/M2, you won't be able to run `docker` commands inside a Dev Container; either use Codespaces or do not open the Dev Container.\n\n1. Build the image:\n\n    ```shell\n    docker build --tag fastapi-app ./src\n    ```\n\n2. Run the image:\n\n    ```shell\n    docker run --publish 3100:3100 fastapi-app\n    ```\n\n### Deployment\n\nThis repo is set up for deployment on Azure Container Apps using the configuration files in the `infra` folder.\n\nThis diagram shows the architecture of the deployment:\n\n![Diagram of app architecture: Azure Container Apps environment, Azure Container App, Azure Container Registry, Container, and Key Vault](readme_diagram.png)\n\nSteps for deployment:\n\n1. Sign up for a [free Azure account](https://azure.microsoft.com/free/) and create an Azure Subscription.\n2. Install the [Azure Developer CLI](https://learn.microsoft.com/azure/developer/azure-developer-cli/install-azd). (If you open this repository in Codespaces or with the VS Code Dev Containers extension, that part will be done for you.)\n3. Login to Azure:\n\n    ```shell\n    azd auth login\n    ```\n\n4. Provision and deploy all the resources:\n\n    ```shell\n    azd up\n    ```\n\n    It will prompt you to provide an `azd` environment name (like \"fastapi-app\"), 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.\n\n5. When `azd` has finished deploying, you'll see an endpoint URI in the command output. Visit that URI, and you should see the API output! 🎉\n6. When you've made any changes to the app code, you can just run:\n\n    ```shell\n    azd deploy\n    ```\n\n### Costs\n\nPricing varies per region and usage, so it isn't possible to predict exact costs for your usage.\nThe majority of the Azure resources used in this infrastructure are on usage-based pricing tiers.\nHowever, Azure Container Registry has a fixed cost per registry per day.\n\nYou can try the [Azure pricing calculator](https://azure.com/e/9f8185b239d240b398e201078d0c4e7a) for the resources:\n\n- 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. [Pricing](https://azure.microsoft.com/pricing/details/container-apps/)\n- Azure Container Registry: Basic tier. [Pricing](https://azure.microsoft.com/pricing/details/container-registry/)\n- Log analytics: Pay-as-you-go tier. Costs based on data ingested. [Pricing](https://azure.microsoft.com/pricing/details/monitor/)\n\n⚠️ To avoid unnecessary costs, remember to take down your app if it's no longer in use,\neither by deleting the resource group in the Portal or running `azd down`.\n\n\n## Getting help\n\nIf you're working with this project and running into issues, please post in **Discussions**.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpamelafox%2Fsimple-fastapi-container","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpamelafox%2Fsimple-fastapi-container","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpamelafox%2Fsimple-fastapi-container/lists"}