- Lab
- A Cloud Guru
Cloud Run Data in GCS and Firestore
In this lab, we'll deploy a basic image gallery app with Cloud Run, and then refactor it so it uses Cloud Storage instead of local file system storage. Then, we'll add the ability to add metadata to images, which we'll store in the Cloud Firestore NoSQL database. You should be familiar with the GCP console and Cloud Shell to perform this hands-on lab. Some experience with Python will be beneficial.
Path Info
Table of Contents
-
Challenge
Deploy the image-gallery App to Cloud Run
- Download the image-gallery code from the course GitHub repo.
- Build the container image from the
1-local-storage
directory. - Deploy the container to Cloud Run.
- Upload a picture of a dog (any dog will do).
-
Challenge
Refactor the App to Use Cloud Storage
- Create a Cloud Storage bucket for image uploads.
- Refactor the code to use Cloud Storage instead of local storage. You can refer to the updated code in
2-cloud-storage
, or just use the code in that directory instead of updating your own. Don't forget to change the value ofBUCKET_NAME
. - Rebuild the container and deploy the updated version of the app to Cloud Run, using
gcloud run deploy options of --cpu=2 --max-instances=1 --memory=4Gi
. - Re-upload your dog picture.
- Deploy a new revision to force the instance to be removed and recreated. The image you uploaded should persist.
-
Challenge
Deploy the Cloud Firestore Version of the App
- Go to the Cloud Firestore section in the GCP console, and enable Firestore in Native Mode. Choose the us-east1 region.
- Refactor the code to use Cloud Firestore in addition to Cloud Storage. You can refer to the updated code in
3-firestore
, or just use the code in that directory instead of updating your own. - Rebuild the container and deploy the updated version of the app to Cloud Run.
- Upload a dog picture with a description. You should see the image uploaded to Cloud Storage and a document created in Cloud Firestore.
What's a lab?
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.