Zkt22/z3/README.md

114 lines
4.8 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Fruit app
## Overview of the APP
The application consist of two parts, an API and a front end. The application displays 5 fruits which are seeded to the database at the startup. The get API provides the list of fruits. Anyone can like a fruit. In this case the count of like will be increased.
![homepage](./src/images/homepage.png?raw=true 'System Architecture')
## Technology used
- Flask (Backend Rest API)
- Angular (Frontend)
- MySQL - as persistent database
- Azure
- Docker
## prerequist:
- mysql-client : https://dev.mysql.com/downloads/shell/
- az command line.
## Azure public Cloud :
Microsoft Azure, generally known as Azure, is a cloud computing service provided by Microsoft. It provides over two hundred cloud products and services developed to address today's concerns. This cloud was applied to deploy our fruit-app application on the cloud.
Here is a list of used services:
- **Resource group**: Azure Resource Groups (ARGs) are logical groups of Azure services. It is used to organise a collection of services in order to manage them more easily.
- **Azure App Service**: Platform as a Solution (Platform as a service) is a service that allows you to design, maintain, and deploy organisation scaled web apps without having to handle the network technology.
- **ACR**: Azure Container registry of Docker images to store our images.
- **Mysql Database**: One of zure services to create/manage databases (like mysql or postgresql).
- **Identity Access management(IAM)**: is a web service that helps securely control access to Azure resources. We use IAM to control who is authenticated (signed in) and authorized (has permissions) to use resources.
## Folder structure:
Description of the folder structure:
- **src**: contain the application code
- **prepare-app.sh**: Script to build the docker image for the application and deploy the app to the azure cloud using commands
- **stop-app.sh** Script to stop and remove the app
- **README.md**: Documentation file
- **az-docker-compose.yml**: Docker compose for the webapp for azure configuration.
## Methode of communication:
For the communication between:
- Mysql-backend: The credentials for mysql are passed to the backend application as environement variables.
- frontend-backend: For the connection between the frontend and backend, we used the nginx base image for our frontend image. Also ConfigMap is used to store nginx configuration file to forward all the `/api` request to the backend service.
## How to prepare, run, pause and delete the application.
### Prepare the app
Now to prepare the application you have to run the command :
```
sh prepare-app.sh
```
the script which will create a resource group named 'suhailgroup' and will add all the required services for our application to run.
### To stop the app
The `stop-app.sh` script will remove the resources group and all the created services related to that group.
## Workflow:
Here is our deployment workflow:
1 - Create a local image of our application.
2- Construct a resource group to group our application services so that they can be managed as a single entity afterwards.
3- Create a azure container registry to store our application image.
4- Tag and upload the previously produced photos to the ACR registry.
5 - Create and provide access to an Identity service so that we may use it to extract our photos from the web app service later.
6- Creating Mysql database and padate the firewall rule to allow external access to database.
7 - Create the webapp service for our application (we used the —acr-identity argument to provide the previously built Identity role and a docker-compose to run for the application) as well as giving the environment variables for database access to that webapp containers.
## How to view the application on the web.
The application is accessible through: `https://suhail5742.azurewebsites.net/`
## Restart the service on failure:
In order to have a heigh availibiity for our application, we added the `restart` docker option ,to restart our containers if they exits due to an error:
```
restart: on-failure:5
```
## resources:
[Deploy docker image to azure webapp](https://www.azuredevopslabs.com/labs/vstsextend/docker/)
[Create web app in azure](https://docs.microsoft.com/en-us/azure/devops/pipelines/apps/cd/deploy-docker-webapp?view=azure-devops&tabs=java%2Cyaml)
[Docker compose options for azure](https://docs.microsoft.com/en-us/azure/app-service/configure-custom-container?pivots=container-linux#docker-compose-options)
[Azure Mysql Service](https://azure.microsoft.com/en-us/services/mysql/#overview)
[Azure web app Commands](https://docs.microsoft.com/en-us/cli/azure/webapp?view=azure-cli-latest)
[Azure identity management](https://docs.microsoft.com/en-us/azure/active-directory/fundamentals/active-directory-whatis)