/rangrang-server

This repository holds the Mobile Application files for RangRang, a Bangkit 2021 Capstone Project aimed to teach young children the skill of identifying their surroundings. RangRang is an application that combines the 3 learning paths taught in Bangkit 2021, Mobile Development, Cloud Computing, and Machine Learning.

Primary LanguagePython

RangRang - Server

logo

python Django djangorestframework TensorFlow 2.5 Protobuf Compiler >= 3.0

web

Steps to Replicate the Server Deployment

  1. Open the Google Cloud Platform
  2. To grant an IAM role as Editor VM on a project, do the following:
    • In the Cloud Console, go to the IAM page
    • Go to the IAM page
    • Click Add
    • Enter an email e.g example@gmail.com,
    • Choose the Roles under the Compute Engine Role and Select 'Compute Engine Admin'
    • Click Save
  3. Go into the Cloud Console
  4. To Provision a New Compute Instance for the Back-End Server, Run the Following Commands
    gcloud beta compute --project=<YOUR PROJECT ID> instances create rangrang-backend --zone=asia-southeast2-b --machine-type=n1-standard-2 --subnet=default --address=34.101.140.95 --network-tier=PREMIUM --maintenance-policy=TERMINATE --service-account=1083353886178-compute@developer.gserviceaccount.com --scopes=https://www.googleapis.com/auth/cloud-platform --tags=http-server,https-server --image=ubuntu-2004-focal-v20210603 --image-project=ubuntu-os-cloud --boot-disk-size=10GB --boot-disk-type=pd-ssd --boot-disk-device-name=rangrang-backend --no-shielded-secure-boot --shielded-vtpm --shielded-integrity-monitoring --reservation-affinity=any
    
    gcloud compute --project=<YOUR PROJECT ID> firewall-rules create default-allow-http --direction=INGRESS --priority=1000 --network=default --action=ALLOW --rules=tcp:80 --source-ranges=0.0.0.0/0 --target-tags=http-server
    
    gcloud compute --project=<YOUR PROJECT ID> firewall-rules create default-allow-https --direction=INGRESS --priority=1000 --network=default --action=ALLOW --rules=tcp:443 --source-ranges=0.0.0.0/0 --target-tags=https-server
    
  5. SSH into the Server either by GUI, or through the Command Line Interface
  6. Update Packages on the Ubuntu VM by Running the Following Commands
    sudo apt update && sudo apt upgrade -y
  7. Setup Machine Learning Dependencies with the Following Commands
    • Clone models repository from tensorflow
      git clone https://github.com/tensorflow/models.git
    • Install tensorflow object detection API
      cd models/research
      protoc object_detection/protos/*.proto --python_out=.
      cp object_detection/packages/tf2/setup.py .
      sudo pip3 install --use-feature=2020-resolver .
  8. Clone This Repository by Running the Following Command
    git clone https://github.com/Hyuto/rangrang-server.git
    cd rangrang-server
  9. Install Django, djangorestframework and whitenoise
    sudo pip3 install django djangorestframework whitenoise
  10. Setup django application
    • Setup main directory
      mkdir static files
    • Migrate db
      python3 manage.py migrate
    • Collectstatic
      python3 manage.py collectstatic
  11. Exit the SSH Session by Running:
    exit
  12. Turn off the VM Instance for the Back End Server by
  • Clicking on the Checkbox of the VM that is Going to be Turned Off
  • On the Top Panel, Click Stop
  1. Click on the Back End Server VM then Click on the Edit Button.
  2. Navigate to the Custom metadata Section, and add the Following:
    Key: startup-script
    Value:
    #! /bin/bash
    sudo service apache2 stop
    cd /home/rangrang-server
    sudo nohup python3 manage.py runserver 0.0.0.0:80 >> log.log 2>&1 | tee &
  3. Save the Changes
  4. Turn on the VM Instance to Start the Back End Server Service
  5. Navigate to the External IP Address to Check Its Availability by Going to these Paths:
    http://<EXTERNAL-IP-ADDRESS>/cd-api/video/
    http://<EXTERNAL-IP-ADDRESS>/cd-api/picture/
    http://<EXTERNAL-IP-ADDRESS>/od-api/video/
    http://<EXTERNAL-IP-ADDRESS>/od-api/picture/
    

Once all the Paths are Working, the Server is Considered Fully Functioning and Ready to Use

Navigation

Repository
Android grrrracia/RangRang-MobileApp
Cloud Computing Hyuto/rangrang-server
Machine Learning Hyuto/rangrang-ML