Skip to content
Open
Show file tree
Hide file tree
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
67 changes: 25 additions & 42 deletions eventarc-agentic-workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@ To deploy this sample (on Linux/macOS), you need:
* **Terraform**: Follow the official
[Terraform installation instructions](https://developer.hashicorp.com/terraform/install).

* **Docker**: Follow the
[official Docker installation instructions](https://docs.docker.com/get-docker/).
A modern version of Docker supporting **Docker Buildx** is required.

* **Python**: Ensure [Python >=3.12](https://www.python.org/downloads/) is
installed.

### Windows Compatibility

The deployment scripts and commands in this repository are written for Bash and
Expand Down Expand Up @@ -87,8 +80,8 @@ and create resources in the Main Project `$PROJECT_ID`. Broadly, **Project
Owner** or **Project Editor** combined with **Project IAM Admin** is required to
allow Terraform to:

- Enable required APIs (Eventarc, Cloud Run, Agent Platform/Vertex AI,
Artifact Registry).
- Enable required APIs (Eventarc, Cloud Run, Cloud Build, Agent
Platform/Vertex AI, Artifact Registry).
- Create Service Accounts for agents and invokers.
- Grant IAM permissions (e.g., Eventarc Message Bus User, Vertex AI User,
Cloud Run Invoker).
Expand Down Expand Up @@ -133,15 +126,6 @@ house the state file.
gcloud storage buckets create gs://$TFSTATE_BUCKET --project=$PROJECT_ID --location=$REGION
```

### Docker Authentication

To pull and push images to Google Artifact Registry during deployment, configure
Docker to authorize with the Artifact Registry:

```bash
gcloud auth configure-docker $REGION-docker.pkg.dev --project=$PROJECT_ID
```

## 3. Configuration

1. Copy the example configuration file:
Expand Down Expand Up @@ -187,7 +171,8 @@ demo stack using a single command:

> [!NOTE]
>
> Visit the [Troubleshooting](#troubleshooting) section in case you run into issues.
> Visit the [Troubleshooting](#troubleshooting) section in case you run into
> issues.

<details>

Expand Down Expand Up @@ -293,36 +278,24 @@ directory. To add a new service:
`services/my_custom_service`).
2. Add a `Dockerfile` in that directory that describes how to build your
service.
3. If your service needs access to shared tools or other directories outside
its own folder during build, you can add a `docker-compose.yaml` file in the
service directory to define additional build contexts.
4. Update `demo.yaml` in the config directory to define the new service and
point `src_dir` to your new directory (e.g., `services/my_custom_service`).

Example `docker-compose.yaml` (optional):
> [!IMPORTANT]
>
> The build system (both Cloud Build for production and `run_local.py` for
> local testing) runs from the **repository root**. Your `Dockerfile` must
> assume the build context is the root directory and use paths relative to
> the root (e.g., `COPY services/shared_tools /app/shared_tools/`).

```yaml
services:
agent:
build:
context: .
dockerfile: Dockerfile
additional_contexts:
shared_tools: ../shared_tools
```

The build system will automatically use `docker buildx bake` if a
`docker-compose.yaml` file is present in the service's `src_dir`, or fall back
to `docker buildx build` if only a `Dockerfile` is present.
3. Update `demo.yaml` in the config directory to define the new service and
point `src_dir` to your new directory (e.g., `services/my_custom_service`).

## Adding a New ADK Agent
## Adding a New Agent

To add a new ADK agent:
To add a new agent:

1. Create a directory under `services/agents/` (or use
`services/agents/adk_a2a_agent` as a template).
2. Ensure it has a `Dockerfile` and optionally a `docker-compose.yaml` as
described above.
2. Ensure it has a `Dockerfile` as described above.
3. Update `demo.yaml` in the config directory to define the new service and
point `src_dir` to your new directory (e.g.,
`services/agents/my_new_agent`).
Expand All @@ -339,6 +312,16 @@ running the commands below.

<summary><b>Local Development Setup</b></summary>

## Prerequisites

* **Docker**: Follow the
[official Docker installation instructions](https://docs.docker.com/get-docker/).

* **Python**: Ensure [Python >=3.12](https://www.python.org/downloads/) is
installed.

## Virtual Environment

Run the following commands in the root of the repository to set up the
development environment:

Expand Down
21 changes: 21 additions & 0 deletions eventarc-agentic-workflows/cloudbuild.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
steps:
- name: "gcr.io/cloud-builders/docker"
entrypoint: "bash"
args: ["-c", "docker pull $_TAG_LATEST || exit 0"]
- name: "gcr.io/cloud-builders/docker"
args:
[
"build",
"-t",
"$_TAG_SPECIFIC",
"-t",
"$_TAG_LATEST",
"--cache-from",
"$_TAG_LATEST",
"-f",
"$_DOCKERFILE",
".",
]
images:
- "$_TAG_SPECIFIC"
- "$_TAG_LATEST"
5 changes: 5 additions & 0 deletions eventarc-agentic-workflows/infra/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ resource "google_project_service" "aiplatform_api" {
disable_on_destroy = false
}

resource "google_project_service" "cloud_build_api" {
service = "cloudbuild.googleapis.com"
disable_on_destroy = false
}

resource "google_artifact_registry_repository" "demo_repo" {
location = var.region
repository_id = local.artifact_registry_repo_id
Expand Down
8 changes: 1 addition & 7 deletions eventarc-agentic-workflows/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,7 @@ resource "terraform_data" "service_build_push" {

provisioner "local-exec" {
command = <<EOT
# linux/amd64 platform is necessary for cross-platform builds to be compatible with Cloud Run.
if [ -f "${each.value.src_dir}/docker-compose.yaml" ]; then
(cd ${each.value.src_dir} && BUILDX_BAKE_ENTITLEMENTS_FS=0 docker buildx bake --set *.platform=linux/amd64 --set *.tags=${var.region}-docker.pkg.dev/${local.artifact_registry_project}/${local.artifact_registry_repo_id}/${each.key}:${local.service_hashes[each.key]})
else
docker buildx build --platform linux/amd64 -t ${var.region}-docker.pkg.dev/${local.artifact_registry_project}/${local.artifact_registry_repo_id}/${each.key}:${local.service_hashes[each.key]} ${each.value.src_dir}
fi
docker push ${var.region}-docker.pkg.dev/${local.artifact_registry_project}/${local.artifact_registry_repo_id}/${each.key}:${local.service_hashes[each.key]}
gcloud builds submit --config cloudbuild.yaml --substitutions _TAG_SPECIFIC=${var.region}-docker.pkg.dev/${local.artifact_registry_project}/${local.artifact_registry_repo_id}/${each.key}:${local.service_hashes[each.key]},_TAG_LATEST=${var.region}-docker.pkg.dev/${local.artifact_registry_project}/${local.artifact_registry_repo_id}/${each.key}:latest,_DOCKERFILE=${each.value.src_dir}/Dockerfile --project ${local.artifact_registry_project} .
EOT
interpreter = ["bash", "-c"]
}
Expand Down
14 changes: 6 additions & 8 deletions eventarc-agentic-workflows/scripts/run_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,12 @@ def main():

else:
print(f"🔨 Building Docker image for {agent_name}...")
if os.path.exists(os.path.join(config["src_dir"], "docker-compose.yaml")):
build_cmd = (
"BUILDX_BAKE_ENTITLEMENTS_FS=0 docker buildx bake --set"
f" *.tags=local-{agent_name}"
)
else:
build_cmd = f"docker buildx build -t local-{agent_name} ."
subprocess.run(build_cmd, shell=True, check=True, cwd=config["src_dir"])
repo_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
build_cmd = (
f"docker build -t local-{agent_name} -f"
f" {config['src_dir']}/Dockerfile ."
)
subprocess.run(build_cmd, shell=True, check=True, cwd=repo_root)

print(f"🚀 Starting {agent_name} locally on port 8081...")
print("👉 Listening for requests on: http://localhost:8081")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ ENV STARTUP_MODE="a2a"
WORKDIR /app

# Cache the dependency layer
COPY requirements.txt /app/requirements.txt
COPY services/agents/adk_a2a_agent/requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir uvicorn -r /app/requirements.txt

# Copy shared_tools from additional context
COPY --from=shared_tools . /app/shared_tools/
# Copy shared_tools
COPY services/shared_tools /app/shared_tools/

# Copy the agent code to /app/agents/adk_a2a_agent
WORKDIR /app/agents/adk_a2a_agent
COPY . .
# Copy the agent code
COPY services/agents/adk_a2a_agent /app/agents/adk_a2a_agent

# Tell Python to look in /app
ENV PYTHONPATH=/app
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ ENV GOOGLE_GENAI_USE_VERTEXAI=1
WORKDIR /app

# Cache the dependency layer
COPY requirements.txt /app/requirements.txt
COPY services/agents/adk_mcp_agent/requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir -r /app/requirements.txt

# Copy shared_tools from additional context
COPY --from=shared_tools . /app/shared_tools/
# Copy shared_tools
COPY services/shared_tools /app/shared_tools/

# Copy the agent code to /app/agents/adk_mcp_agent
WORKDIR /app/agents/adk_mcp_agent
COPY . .
# Copy the agent code
COPY services/agents/adk_mcp_agent /app/agents/adk_mcp_agent

# Tell Python to look in /app
ENV PYTHONPATH=/app
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ ENV GOOGLE_GENAI_USE_VERTEXAI=1
WORKDIR /app

# Cache the dependency layer
COPY requirements.txt /app/requirements.txt
COPY services/agents/langchain_mcp_agent/requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir -r /app/requirements.txt

# Copy shared_tools from additional context
COPY --from=shared_tools . /app/shared_tools/
# Copy shared_tools
COPY services/shared_tools /app/shared_tools/

# Copy the agent code to /app/agents/langchain_mcp_agent
WORKDIR /app/agents/langchain_mcp_agent
COPY . .
# Copy the agent code
COPY services/agents/langchain_mcp_agent /app/agents/langchain_mcp_agent

# Tell Python to look in /app
ENV PYTHONPATH=/app
Expand Down

This file was deleted.

4 changes: 2 additions & 2 deletions eventarc-agentic-workflows/services/log_events/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ FROM node:22-alpine
WORKDIR /usr/src/app

# Copy application dependency manifests
COPY package*.json ./
COPY services/log_events/package*.json ./

# Install production dependencies
RUN npm install --only=production

# Copy local code to the container image
COPY . ./
COPY services/log_events ./

# Run the web service on container startup
CMD [ "npm", "start" ]
9 changes: 4 additions & 5 deletions eventarc-agentic-workflows/services/store/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ ENV PORT=8080
WORKDIR /app

# Cache the dependency layer
COPY requirements.txt /app/requirements.txt
COPY services/store/requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir -r /app/requirements.txt

# Copy shared_tools from additional context
COPY --from=shared_tools . /app/shared_tools/
# Copy shared_tools
COPY services/shared_tools /app/shared_tools/

# Copy the service code
WORKDIR /app/services/store
COPY . .
COPY services/store /app/services/store

# Tell Python to look in /app
ENV PYTHONPATH=/app
Expand Down
7 changes: 0 additions & 7 deletions eventarc-agentic-workflows/services/store/docker-compose.yaml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ ENV PORT=8080
WORKDIR /app

# Cache the dependency layer
COPY requirements.txt /app/requirements.txt
COPY services/third_party_shipment/requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir fastapi uvicorn -r /app/requirements.txt

# Copy shared_tools from additional context
COPY --from=shared_tools . /app/shared_tools/
# Copy shared_tools
COPY services/shared_tools /app/shared_tools/

# Copy the service code
WORKDIR /app/services/third_party_shipment
COPY . .
COPY services/third_party_shipment /app/services/third_party_shipment

# Tell Python to look in /app
ENV PYTHONPATH=/app
Expand Down

This file was deleted.