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 all 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](https://firebase.google.com/docs/emulator-suite), which you can use with Genkit.

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 the Genkit framework in development mode, which launches and exposes the Genkit reflection API (but not the Dev UI).

Then, launch the Genkit Dev UI with the `--attach` option to connect it to your code running inside the Firebase Emulator:

```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.
Loading