Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added firebase emulator instructions #100

Merged
merged 8 commits into from
May 13, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions docs/firebase.md
Original file line number Diff line number Diff line change
Expand Up @@ -308,3 +308,23 @@ app:
Open the web app by visiting the URL printed by the `deploy` command. The app
requires you to sign in with a Google account, after which you can initiate
endpoint requests.

## Developing using Firebase Local Emulator Suite

Firebase offers a suite of emulators for local development and you can use Genkit with [Firebase Local Emulator Suite](https://firebase.google.com/docs/emulator-suite).
pavelgj marked this conversation as resolved.
Show resolved Hide resolved

To use Genkit with the Firebase Emulator Suite, start the the Firebase emulators like this:

```bash
GENKIT_ENV=dev firebase emulators:start --inspect-functions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this sufficient? I've got the following:

"serve-genkit": "npm run build && GENKIT_ENV=dev GENKIT_REFLECTION_ON_STARTUP_FAILURE=ignore firebase emulators:start --inspect-functions"

I haven't tried which is the absolute essential number of parameters to make it work...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We made a few changes, GENKIT_REFLECTION_ON_STARTUP_FAILURE is not necessary now.

```

this will run your code in the emulator and run genkit framework in dev mode which launches and exposes the Genkit reflection API (but not the Dev UI).
pavelgj marked this conversation as resolved.
Show resolved Hide resolved

To launch the Genkit Dev UI that talks to your code running inside the Firebase Emulator run this command:
pavelgj marked this conversation as resolved.
Show resolved Hide resolved

```bash
genkit start --attach http://localhost:3100 --port 4001
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have

"genkit-emulator": "GCLOUD_PROJECT=fir-genkit-fundamental-01 && genkit start --attach http://localhost:3100 --port 4444",

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In attach mode runtime env var (e.g. GCLOUD_PROJECT) are not required.

```

To see traces from Firestore in the Dev UI you can navigate to the Inspect tab and toggle the "Dev/Prod" switch. When toggled to "prod" it will be loading traces from firestore.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which Firestore instance, exactly, will the traces be fetched from?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That depends... if you have firestore emulator configured then it will pull from emulated firestore, if not then from prod.

Loading