This web application is designed to simplify blood donation by directly connecting donors and requester without intermediaries. All users register under a single system, where they can act as both donors and requester. Once registered, users needing blood can submit a request, while donors simply wait to receive notifications about nearby requests.
The goal is to make the donation process faster and more efficient, reducing the time involved in finding a suitable donor. The platform prioritizes simplicity, ensuring a user-friendly experience with minimal steps.
Before starting deploying the instances, there are two ways to do this, either using a single virtual machine or dual wtih ansible, which one of the vm will be the control node, and the second vm will be the worker node.
Below are two different topologies of each infrastructure we are using.
- Terraform installed
- Cloud provider credentials set up (e.g., AWS, GCP, Azure)
First will have to clone this repository
Note
For nginx setup instructions go here
git clone git@github.com:CAA900-PRIME/blooddonation-cloud.gitImportant
Please ensure:
- Install Azure CLI. Windows and macOS
- Configure Azure locally and ensure connectin to the azure api.
- Azure CLI Documentation
Generate SSH key
ssh-keygen -t rsa -b 4096 -f ./bd_keyWill also need to login to Azure using Azure CLI before using terraform. To login using azure cli:
az loginA web page will open in a new tab, must login manually. Next, will need to modify the subscription id within
# Configure the Microsoft Azure Provider
provider "azurerm" {
features {}
subscription_id = "" # Must be provided
}Note
As this repository holds two different infrastrucutres, the default option will be using a single virtual machine. The other option is using 2 virtual machines and ansible. Don't forget to configure the main.tf files.
Change the working directory to terrform/single_vm
cd terraform/single_vmInitialize and downloads provider plugins and sets up the backend for storing state.
terraform initThe following command shows what actions Terraform will take without applying
terraform planAnd to apply the changes required to reach the desired state defined in the configuration
terraform apply --auto-approveConnect to Azure VM
ssh -i bd_key azureu@ip-addressAfter loging in, will start the following servers:
- Running mysql through docker.
- Running the backend
- Running the frontend
Will ues tmux to manage and run all server processes in detached sessions, ensuring that they continue running even if the connection is lost.
terraform initInitialize terraformterraform planShow what its going to be built before applying the changes.terraform apply --auto-approveApply the changes to the cloud.terraform validatevalidates the configuration files for syntax errors.terraform fmtFormatting the file.terraform destroyDestroyes all the resources managed by the current configuration.
install Ansible
sudo apt update
sudo apt install ansible -yExecute the Ansible Playbook
ansible-playbook -i inventory.ini deploy_applications.ymlThe objective is to deploy a virtual machine (VM) in the cloud, install Docker, and utilize Ansible to automate the deployment and management of services—such as the backend, frontend, and MySQL database—within Docker containers. This approach ensures a streamlined, consistent, and efficient deployment process.
Deploy a VM instance using your chosen cloud provider (e.g., AWS, Azure, GCP).
Use Ansible to automate the installation of Docker on the VM. Create an Ansible playbook that installs Docker and its dependencies.
Create Dockerfiles for each service (backend, frontend, MySQL) defining their environments. Build and test these images locally before deployment.
Push the built images to a container registry (e.g., Docker Hub, AWS ECR) for accessibility.
Develop playbooks to pull the Docker images from the registry and run them as containers on the VM. Define tasks to manage container orchestration, networking, and environment variables.
Run the playbooks to automate the deployment of services within Docker containers on the VM. Ensure proper sequencing and dependencies are managed.
Implement monitoring solutions to track the health and performance of the services. Use Ansible for ongoing configuration management and updates.

