GSP-344: Serverless Firebase Development
Overview
Start by executing the following commands:
1gcloud config set project $(gcloud projects list --format='value(PROJECT_ID)' --filter='qwiklabs-gcp')
2git clone https://github.com/rosera/pet-theory.git
Task - 1: Firestore Database Create
Go to Firestore
> Select Naive Mode
> Location: nam5
> Create Database
Task - 2: Firestore Database Populate
1cd pet-theory/lab06/firebase-import-csv/solution
2npm install
3node index.js netflix_titles_original.csv
Task - 3: Cloud Build Rest API Staging
1cd ~/pet-theory/lab06/firebase-rest-api/solution-01
2npm install
3gcloud builds submit --tag gcr.io/$GOOGLE_CLOUD_PROJECT/rest-api:0.1
4gcloud beta run deploy netflix-dataset-service --image gcr.io/$GOOGLE_CLOUD_PROJECT/rest-api:0.1 --allow-unauthenticated
- Choose 1 and us-central1
Task - 4: Cloud Build Rest API Production
1cd ~/pet-theory/lab06/firebase-rest-api/solution-02
2npm install
3gcloud builds submit --tag gcr.io/$GOOGLE_CLOUD_PROJECT/rest-api:0.2
4gcloud beta run deploy netflix-dataset-service --image gcr.io/$GOOGLE_CLOUD_PROJECT/rest-api:0.2 --allow-unauthenticated
- Goto cloud run and click
netflix-dataset-service
then copy the url.
1SERVICE_URL=<copy url from your netflix-dataset-service>
2curl -X GET $SERVICE_URL/2019
Task - 5: Cloud Build Frontend Staging
1cd ~/pet-theory/lab06/firebase-frontend/public
2nano app.js # comment line 3 and uncomment line 4, insert your netflix-dataset-service url
3npm install
4cd ~/pet-theory/lab06/firebase-frontend
5gcloud builds submit --tag gcr.io/$GOOGLE_CLOUD_PROJECT/frontend-staging:0.1
6gcloud beta run deploy frontend-staging-service --image gcr.io/$GOOGLE_CLOUD_PROJECT/frontend-staging:0.1
- Choose 1 and us-central1
Task - 6: Cloud Build Frontend Production
1gcloud builds submit --tag gcr.io/$GOOGLE_CLOUD_PROJECT/frontend-production:0.1
2gcloud beta run deploy frontend-production-service --image gcr.io/$GOOGLE_CLOUD_PROJECT/frontend-production:0.1
- Choose 1 and us-central1
Congratulations, you're all done with the lab 😄