Skip to content
Star
478
Star
478

NoSQL Writer

This guide shows you how to work with Google Cloud Run and Firestore locally using the Firebase Emulator Suite and Python. This lab demonstrates how to create a containerized service that registers patients in Firestore.

  1. Setup Environment:

    Open VS Code in the project folder and execute this command in the Command Palette:

    Terminal window
    > Dev Containers: Reopen in Container
  2. Start Firebase Emulators:

    Terminal window
    firebase emulators:start
  3. Run the Service:

    Open a new terminal and build and run the service container:

    Terminal window
    docker build -t patient-service ./app
    docker run --rm -p 8080:8080 --net=host -e FIRESTORE_EMULATOR_HOST=localhost:8081 patient-service
  4. Run the Example:

    Terminal window
    python main.py

Open the Firebase Emulator UI and navigate to Firestore to verify the registered patient documents:

Terminal window
http://localhost:4000
Terminal window
docker stop patient-service
pkill -f firebase
IssueSolution
Connection Refused (Firestore)Ensure firebase emulators:start is running. On Linux with Minikube, change FIRESTORE_EMULATOR_HOST to host.minikube.internal:8081 in .vscode/launch.json.
Persistent Google Cloud login promptsEnsure .vscode/settings.json includes "cloudcode.useGcloudAuthSkaffold": false and select No/Cancel when prompted.
Firebase Emulator fails to startEnsure Node.js and Java JDK are installed. Check ports 8081 and 4000 are available.