Skip to content

anhminhbo/BITS-Pomodoro-Music

Repository files navigation

Building IT Systems RMIT

Pomodoro Music player Tested on Chrome - Desktop/Laptop - may not work properly on other browsers and mobile platforms

Software Architecture

Software architecture(new)

Software architecture(old)

Local Development pipeline

Local Development pipeline

To start project locally

  • Clone source code
git clone https://{{username}}:{{access_token}}@github.com/anhminhbo/BITS-Pomodoro-Music.git
  • Make sure your computer install docker and docker-compose or else:

Install Docker (Windows)

docker -v
docker-compose -v
  • Congrats you are done, if there are any bugs or errors please contact Mr Bug Fix Wanderer/anhminhbo <3

Install Docker and Docker-compose (Linux, MacOs)

  • Uninstall old docker or docker-compose
sudo apt-get remove docker docker-engine docker.io containerd runc
  • Install docker and docker-compose
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
  • Checking docker and docker-compose version
docker -v
docker-compose -v

Start project by running script

  • Make sure you are using a bash terminal to run the following code

Start to do frontend part

bash -x local_startup.sh

Start to do backend part

bash -x local_startup.sh backend

After finish development, clean up everything

  • Make sure you are using a bash terminal to run the following code
bash -x clean-up.sh

Start

  • Testing docker local env on your local machine
bash -x testing_docker_prod.sh

How to merge master branch into your development branch for devs

  • Make sure you are using a bash terminal to run the following code
  • First arg is the name of the branch you want to merge, Second arg is your commit message for your current branch
  • For all frontend members
bash push_current_and_merge.sh mirror ""
  • Only frontend teamleader
bash push_current_and_merge.sh minh-dev ""
  • Only project leader
bash push_current_and_merge.sh main ""

Integrate Github action for automation to create PR

  • Whenever a dev using the push_current_and_merge.sh script, it will automatically trigger Github action to create a PR to mirror(Master Frontend Leader)
  • Whenever mirrorusing the push_current_and_merge.sh script, it will automatically trigger Github action to create a PR to minh-dev(Team Leader)
  • Whenever minh-dev has new codes, github action trigger to create a new PR to main for review
  • (New) Add new github action to automated build and push Docker image instead of old costly Jenkins
  • (New) Add new github action to deploy production after build and push Docker images success

Integrate Jenkins for automation of build, push and deploy(deprecated due to high cost VM)

  • After main branch has new codes, it trigger Jenkins pipeline on Jenkins VM to automate build, push and deploy to production.

Integrate provisioners to migrate infra or init infra or destroy infra

  • Prerequisites
    • Install ansible
    • Install terraform
    • MacOs or Linux platform or Window Bash env
    • Register and buy a domain(Namecheap, GoDaddy, or any domain providers)
    • Install AWS CLI and configure AWS CLI using
    aws configure
    

Notes: When you know your App IP, point your domain to the App IP immediately so it saves time

  • Execute build infra script to provision AWS infra for the app, remember to get a domain first
bash provisioners/build_infra.sh your_domain_here your_frontend_port your_backend_port

Notes: Sometimes the script will stop at Config the VM and not proceed to Apply cert for the web app step. IF you do not see "Done building infrastructure of your web app. Ref: BugFixWanderer", Here how to solve it, type in console in provisioners folder: ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -u ubuntu --key-file aws-ec2-private-key.pem -T 1000 -i ansible_hosts ansible.apply_cert.yaml

  • Remember to read and type "yes" ^^!

  • There will be an interval of 5s to check if you have point your newly domain to the App VM IP or not, please be patient because it takes 0-72h to change globally even if you do correctly, you can manually check by using this command at the meantime when waiting:

nslookup your_domain_here | grep Address | tail -n 1 | cut -d" " -f2
  • If any errors happened, script automatically destroys all the resources to start over, or you can do it manually:
bash provisioners/destroy_infra.sh
  • For troubleshooting produciton env, here how to ssh to production:
ssh -vv ubuntu@your_ec2_ip -i provisioners/aws-ec2-private-key.pem 

Docs

  • Refers to Docker App:here
  • Refers to Terraform & Ansible:here