diff --git a/py/engdoc/compute-engine.mdx b/py/engdoc/compute-engine.mdx new file mode 100644 index 0000000000..438343db79 --- /dev/null +++ b/py/engdoc/compute-engine.mdx @@ -0,0 +1,129 @@ + +

Deploy Genkit to Google Cloud Compute Engine

+A step-by-step guide to setting up a Google Cloud Platform VM, authenticating with GitHub, and running Genkit Python samples. This guide walks you through deploying Genkit on a Google Cloud Compute Engine instance to run the provider-google-genai-hello sample. + +## Create your VM Instance + +First, provision a virtual machine in the Google Cloud Console with the following specifications: + +``` +| Category | Configuration +|---------------|-------------------------------------------------- +| Machine Name | genkit +| Region / Zone | us-central1 / us-central1-a +| Machine Type | E2 (General Purpose) +| OS | Debian GNU/Linux 12 (bookworm) +| Storage | 30 GB Balanced Persistent Disk +| Firewall | Allow HTTP, HTTPS, and Load Balancer health checks +``` + +## Access the VM via SSH + +Open your Google Cloud Shell and connect to your new instance: + +```bash +gcloud compute ssh genkit --zone us-central1-a +``` +Once connected, switch to the root user to ensure permanent permissions for global installations: + +```bash +sudo -i +``` + +## Configure Git and GitHub Authentication + + + 1. Install Git: + + ```bash + apt update && apt install git -y + ``` + + 2. Set your Identity: + + ```bash + git config --global user.name "Your Name" + git config --global user.email "youremail@example.com" + ``` + + 3. Generate SSH Key: + + ```bash + ssh-keygen -t ed25519 -C "youremail@example.com" + # Press Enter for all prompts (no passphrase) + ``` + 4. Add Key to SSH Agent: + + ```bash + eval "$(ssh-agent -s)" + ssh-add ~/.ssh/id_ed25519 + ``` + + 5. Link to GitHub: + + + Run `cat ~/.ssh/id_ed25519.pub` and copy the output. Go to GitHub Settings > SSH and GPG keys > New SSH Key, and paste your public key there. + + 6. Test Connection: + + ```bash + ssh -T git@github.com + ``` + Type 'yes' when prompted + + + +## Clone and Initialize Genkit +Navigate to the Genkit repository and run the automated setup script for Python samples. + +```bash +git clone git@github.com:firebase/genkit.git +cd genkit/py/samples +./setup.sh +export PATH="/root/.local/bin:$PATH" +``` + + During setup: + +- Enter your Gemini API Key when prompted. + +- Enter your GCP Project ID. + +- You can skip other optional prompts. + +## Run the Sample +Follow these steps to launch the Google GenAI hello provider sample: + +```bash +# 1. Load your environment variables +source ~/.environment + +# 2. Navigate to the specific sample +cd provider-google-genai-hello + +# 3. Start the sample +./run.sh +``` + +## Access the Developer UI +To view the Genkit Developer UI from your local browser, you must open port `4000` in the GCP Firewall. + + Create Firewall Rule +1. Go to VPC Network > Firewall in the GCP Console. + +2. Click Create Firewall Rule. + +3. Name: allow-genkit + +4. Targets: All instances in the network + +5. Source IPv4 range: 0.0.0.0/0 (Note: Use your specific IP for better security). + +6. Protocols and ports: Check TCP and enter 4000. + +7. Click Create. + +Launching the UI +Find your VM's External IP address in the VM Instances list and navigate to it in your browser: + +`http://[YOUR_EXTERNAL_IP]:4000`