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.
Successfully complete this lab by achieving the following learning objectives:
- Deploy the image-gallery App to Cloud Run
- Download the image-gallery code from the course GitHub repo.
- Build the container image from the
- Deploy the container to Cloud Run.
- Upload a picture of a dog (any dog will do).
- 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 of
- 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.
- 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.