Flask and Firebase


select your project

gcloud config set project flaskfire-6f1b8


  # build & push the container image
- name: "gcr.io/kaniko-project/executor:latest"
  args: ["--cache=true", "--cache-ttl=48h", "--destination=gcr.io/$PROJECT_ID/todo:latest"]
  # Deploy container image to Cloud Run
- name: "gcr.io/cloud-builders/gcloud"
  args: ['beta', 'run', 'deploy', 'todo', '--image', 'gcr.io/$PROJECT_ID/todo:latest', '--region', 'us-central1', '--allow-unauthenticated', '--platform', 'managed']

build application

gcloud builds submit --config cloudbuild.yaml .

error #1

Step #1: Deployment failed
Step #1: ERROR: (gcloud.beta.run.deploy) Cloud Run error: Container failed to start. Failed to start and then listen on the port defined by the PORT environment variable. Logs for this revision might contain more information.

turns out the real error from the logs is:

Traceback (most recent call last):
  File "app.py", line 12, in <module>
    cred = credentials.Certificate('key.json')
  File "/usr/local/lib/python3.7/site-packages/firebase_admin/credentials.py", line 83, in __init__
    with open(cert) as json_file:
FileNotFoundError: [Errno 2] No such file or directory: 'key.json'

generate key

  1. Project Settings
  2. Settings
  3. Service Account (tab)
  4. Select Python
  5. Generate new private key
  6. Download the file and name it key.json

run build and deploy again

This time it all works, and a url is returned.

Aaron Addleman
Aaron Addleman
Principal Automation Engineer

Fun with programming and infrastructure