1 changed files with 111 additions and 111 deletions
@ -1,111 +1,111 @@ |
|||||||
# Python Flask - Demo Web Application |
# Python Flask - Demo Web Application for NEW COMPANY |
||||||
|
|
||||||
This is a simple Python Flask web application. The app provides system information and a realtime monitoring screen with dials showing CPU, memory, IO and process information. |
This is a simple Python Flask web application. The app provides system information and a realtime monitoring screen with dials showing CPU, memory, IO and process information. |
||||||
|
|
||||||
The app has been designed with cloud native demos & containers in mind, in order to provide a real working application for deployment, something more than "hello-world" but with the minimum of pre-reqs. It is not intended as a complete example of a fully functioning architecture or complex software design. |
The app has been designed with cloud native demos & containers in mind, in order to provide a real working application for deployment, something more than "hello-world" but with the minimum of pre-reqs. It is not intended as a complete example of a fully functioning architecture or complex software design. |
||||||
|
|
||||||
Typical uses would be deployment to Kubernetes, demos of Docker, CI/CD (build pipelines are provided), deployment to cloud (Azure) monitoring, auto-scaling |
Typical uses would be deployment to Kubernetes, demos of Docker, CI/CD (build pipelines are provided), deployment to cloud (Azure) monitoring, auto-scaling |
||||||
|
|
||||||
## Screenshot |
## Screenshot |
||||||
|
|
||||||
 |
 |
||||||
|
|
||||||
# Status |
# Status |
||||||
|
|
||||||
    |
    |
||||||
|
|
||||||
Live instances: |
Live instances: |
||||||
|
|
||||||
[](https://python-demoapp.azurewebsites.net/) |
[](https://python-demoapp.azurewebsites.net/) |
||||||
[](https://python-demoapp.kube.benco.io/) |
[](https://python-demoapp.kube.benco.io/) |
||||||
|
|
||||||
## Building & Running Locally |
## Building & Running Locally |
||||||
|
|
||||||
### Pre-reqs |
### Pre-reqs |
||||||
|
|
||||||
- Be using Linux, WSL or MacOS, with bash, make etc |
- Be using Linux, WSL or MacOS, with bash, make etc |
||||||
- [Python 3.8+](https://www.python.org/downloads/) - for running locally, linting, running tests etc |
- [Python 3.8+](https://www.python.org/downloads/) - for running locally, linting, running tests etc |
||||||
- [Docker](https://docs.docker.com/get-docker/) - for running as a container, or image build and push |
- [Docker](https://docs.docker.com/get-docker/) - for running as a container, or image build and push |
||||||
- [Azure CLI](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-linux) - for deployment to Azure |
- [Azure CLI](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-linux) - for deployment to Azure |
||||||
|
|
||||||
Clone the project to any directory where you do development work |
Clone the project to any directory where you do development work |
||||||
|
|
||||||
``` |
``` |
||||||
git clone https://github.com/benc-uk/python-demoapp.git |
git clone https://github.com/benc-uk/python-demoapp.git |
||||||
``` |
``` |
||||||
|
|
||||||
### Makefile |
### Makefile |
||||||
|
|
||||||
A standard GNU Make file is provided to help with running and building locally. |
A standard GNU Make file is provided to help with running and building locally. |
||||||
|
|
||||||
```text |
```text |
||||||
help 💬 This help message |
help 💬 This help message |
||||||
lint 🔎 Lint & format, will not fix but sets exit code on error |
lint 🔎 Lint & format, will not fix but sets exit code on error |
||||||
lint-fix 📜 Lint & format, will try to fix errors and modify code |
lint-fix 📜 Lint & format, will try to fix errors and modify code |
||||||
image 🔨 Build container image from Dockerfile |
image 🔨 Build container image from Dockerfile |
||||||
push 📤 Push container image to registry |
push 📤 Push container image to registry |
||||||
run 🏃 Run the server locally using Python & Flask |
run 🏃 Run the server locally using Python & Flask |
||||||
deploy 🚀 Deploy to Azure Web App |
deploy 🚀 Deploy to Azure Web App |
||||||
undeploy 💀 Remove from Azure |
undeploy 💀 Remove from Azure |
||||||
test 🎯 Unit tests for Flask app |
test 🎯 Unit tests for Flask app |
||||||
test-report 🎯 Unit tests for Flask app (with report output) |
test-report 🎯 Unit tests for Flask app (with report output) |
||||||
test-api 🚦 Run integration API tests, server must be running |
test-api 🚦 Run integration API tests, server must be running |
||||||
clean 🧹 Clean up project |
clean 🧹 Clean up project |
||||||
``` |
``` |
||||||
|
|
||||||
Make file variables and default values, pass these in when calling `make`, e.g. `make image IMAGE_REPO=blah/foo` |
Make file variables and default values, pass these in when calling `make`, e.g. `make image IMAGE_REPO=blah/foo` |
||||||
|
|
||||||
| Makefile Variable | Default | |
| Makefile Variable | Default | |
||||||
| ----------------- | ---------------------- | |
| ----------------- | ---------------------- | |
||||||
| IMAGE_REG | ghcr<span>.</span>io | |
| IMAGE_REG | ghcr<span>.</span>io | |
||||||
| IMAGE_REPO | benc-uk/python-demoapp | |
| IMAGE_REPO | benc-uk/python-demoapp | |
||||||
| IMAGE_TAG | latest | |
| IMAGE_TAG | latest | |
||||||
| AZURE_RES_GROUP | temp-demoapps | |
| AZURE_RES_GROUP | temp-demoapps | |
||||||
| AZURE_REGION | uksouth | |
| AZURE_REGION | uksouth | |
||||||
| AZURE_SITE_NAME | pythonapp-{git-sha} | |
| AZURE_SITE_NAME | pythonapp-{git-sha} | |
||||||
|
|
||||||
The app runs under Flask and listens on port 5000 by default, this can be changed with the `PORT` environmental variable. |
The app runs under Flask and listens on port 5000 by default, this can be changed with the `PORT` environmental variable. |
||||||
|
|
||||||
# Containers |
# Containers |
||||||
|
|
||||||
Public container image is [available on GitHub Container Registry](https://github.com/users/benc-uk/packages/container/package/python-demoapp) |
Public container image is [available on GitHub Container Registry](https://github.com/users/benc-uk/packages/container/package/python-demoapp) |
||||||
|
|
||||||
Run in a container with: |
Run in a container with: |
||||||
|
|
||||||
```bash |
```bash |
||||||
docker run --rm -it -p 5000:5000 ghcr.io/benc-uk/python-demoapp:latest |
docker run --rm -it -p 5000:5000 ghcr.io/benc-uk/python-demoapp:latest |
||||||
``` |
``` |
||||||
|
|
||||||
Should you want to build your own container, use `make image` and the above variables to customise the name & tag. |
Should you want to build your own container, use `make image` and the above variables to customise the name & tag. |
||||||
|
|
||||||
## Kubernetes |
## Kubernetes |
||||||
|
|
||||||
The app can easily be deployed to Kubernetes using Helm, see [deploy/kubernetes/readme.md](deploy/kubernetes/readme.md) for details |
The app can easily be deployed to Kubernetes using Helm, see [deploy/kubernetes/readme.md](deploy/kubernetes/readme.md) for details |
||||||
|
|
||||||
# GitHub Actions CI/CD |
# GitHub Actions CI/CD |
||||||
|
|
||||||
A working set of CI and CD release GitHub Actions workflows are provided `.github/workflows/`, automated builds are run in GitHub hosted runners |
A working set of CI and CD release GitHub Actions workflows are provided `.github/workflows/`, automated builds are run in GitHub hosted runners |
||||||
|
|
||||||
### [GitHub Actions](https://github.com/benc-uk/python-demoapp/actions) |
### [GitHub Actions](https://github.com/benc-uk/python-demoapp/actions) |
||||||
|
|
||||||
[](https://github.com/benc-uk/python-demoapp/actions?query=workflow%3A%22CI+Build+App%22) |
[](https://github.com/benc-uk/python-demoapp/actions?query=workflow%3A%22CI+Build+App%22) |
||||||
|
|
||||||
[](https://github.com/benc-uk/python-demoapp/actions?query=workflow%3A%22CD+Release+-+AKS%22) |
[](https://github.com/benc-uk/python-demoapp/actions?query=workflow%3A%22CD+Release+-+AKS%22) |
||||||
|
|
||||||
[](https://github.com/benc-uk/python-demoapp/actions?query=workflow%3A%22CD+Release+-+Webapp%22) |
[](https://github.com/benc-uk/python-demoapp/actions?query=workflow%3A%22CD+Release+-+Webapp%22) |
||||||
|
|
||||||
[](https://github.com/benc-uk/python-demoapp/commits/master) |
[](https://github.com/benc-uk/python-demoapp/commits/master) |
||||||
|
|
||||||
## Running in Azure App Service (Linux) |
## Running in Azure App Service (Linux) |
||||||
|
|
||||||
If you want to deploy to an Azure Web App as a container (aka Linux Web App), a Bicep template is provided in the [deploy](deploy/) directory |
If you want to deploy to an Azure Web App as a container (aka Linux Web App), a Bicep template is provided in the [deploy](deploy/) directory |
||||||
|
|
||||||
For a super quick deployment, use `make deploy` which will deploy to a resource group, temp-demoapps and use the git ref to create a unique site name |
For a super quick deployment, use `make deploy` which will deploy to a resource group, temp-demoapps and use the git ref to create a unique site name |
||||||
|
|
||||||
```bash |
```bash |
||||||
make deploy |
make deploy |
||||||
``` |
``` |
||||||
|
|
||||||
## Running in Azure App Service (Windows) |
## Running in Azure App Service (Windows) |
||||||
|
|
||||||
Just don't, it's awful |
Just don't, it's awful |
||||||
|
Loading…
Reference in new issue