Logo NutriKita

REST APIs

Tools

Setup Firebase

Since we are using Firebase & Cloud Firestore in GCP services, we need to configure The Firebase Admin SDK to interact with Firebase from our local environment. To set GOOGLE_APPLICATION_CREDENTIALS environment variable you can follow these steps at the following link: https://firebase.google.com/docs/admin/setup#initialize_the_sdk_in_non-google_environments

Installation

  1. Clone repository
git clone https://github.com/Bangkit-2023-Capstone-CH2-PS307/CC.git
  1. Install dependencies
npm install
  1. Build and run the project
npm run dev

Navigate to http://localhost:8080

API Documentation

We published our API documentation from Postman, you can view it here

CI/CD Workflow

To perform automatic deployment to Cloud Run, we use GitHub Actions to Set up the gcloud CLI/SDK, Build and store a Docker Image to the Artifact Registry, then use the Docker Image from the Artifact Registry deployed to Cloud Run, you can see the full configuration in cloud-run.yml.

Setup GCP Service Account Credentials

  1. You can create service account credentials at the following link: https://cloud.google.com/iam/docs/service-accounts-create
  2. Grant these role to work with GitHub Actions
    • Artifact Registry Administrator
    • Artifact Registry Writer
    • Cloud Run Admin
    • Editor
    • Service Account User
    • Storage Admin
  3. Then, create a service account key at the following link: https://cloud.google.com/iam/docs/keys-create-delete
  4. Download and secure the key. Don't lose it!

Setup GitHub Actions

  1. You can read about GitHub Actions secrets and variable at the following link: https://docs.github.com/en/actions/learn-github-actions/variables
  2. Under GitHub Repository secrets, add these secrets:
    • CLOUD_RUN_SERVICE_NAME (Your Cloud Run service name)
    • GCP_CREDENTIALS (Your GCP Service Account Credentials)
    • PROJECT_ID (Your GCP Project ID)
    • REGION (Your deployed Cloud Run region)
  3. That's all. Just push the code changes to your main branch. And Boom!!!, you can check your Cloud Run deployment url in Google Cloud Console.
Cloud Architecture

Cloud Architecture

Cloud Architecture