From 475895d3ffa6ed9642ba679a877c9f11a4a841a4 Mon Sep 17 00:00:00 2001 From: Tommy Reddad Date: Fri, 24 Apr 2026 20:58:47 +0000 Subject: [PATCH] fix: cache for better performance --- eventarc-agentic-workflows/README.md | 67 +++++++------------ eventarc-agentic-workflows/cloudbuild.yaml | 21 ++++++ eventarc-agentic-workflows/infra/main.tf | 5 ++ eventarc-agentic-workflows/main.tf | 8 +-- .../scripts/run_local.py | 14 ++-- .../services/agents/adk_a2a_agent/Dockerfile | 11 ++- .../agents/adk_a2a_agent/docker-compose.yaml | 7 -- .../services/agents/adk_mcp_agent/Dockerfile | 11 ++- .../agents/adk_mcp_agent/docker-compose.yaml | 7 -- .../agents/langchain_mcp_agent/Dockerfile | 11 ++- .../langchain_mcp_agent/docker-compose.yaml | 7 -- .../services/log_events/Dockerfile | 4 +- .../services/store/Dockerfile | 9 ++- .../services/store/docker-compose.yaml | 7 -- .../services/third_party_shipment/Dockerfile | 9 ++- .../third_party_shipment/docker-compose.yaml | 7 -- 16 files changed, 83 insertions(+), 122 deletions(-) create mode 100644 eventarc-agentic-workflows/cloudbuild.yaml delete mode 100644 eventarc-agentic-workflows/services/agents/adk_a2a_agent/docker-compose.yaml delete mode 100644 eventarc-agentic-workflows/services/agents/adk_mcp_agent/docker-compose.yaml delete mode 100644 eventarc-agentic-workflows/services/agents/langchain_mcp_agent/docker-compose.yaml delete mode 100644 eventarc-agentic-workflows/services/store/docker-compose.yaml delete mode 100644 eventarc-agentic-workflows/services/third_party_shipment/docker-compose.yaml diff --git a/eventarc-agentic-workflows/README.md b/eventarc-agentic-workflows/README.md index 32e9354..5d4a3c7 100644 --- a/eventarc-agentic-workflows/README.md +++ b/eventarc-agentic-workflows/README.md @@ -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 @@ -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). @@ -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: @@ -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.
@@ -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`). @@ -339,6 +312,16 @@ running the commands below. Local Development Setup +## 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: diff --git a/eventarc-agentic-workflows/cloudbuild.yaml b/eventarc-agentic-workflows/cloudbuild.yaml new file mode 100644 index 0000000..8f1e175 --- /dev/null +++ b/eventarc-agentic-workflows/cloudbuild.yaml @@ -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" diff --git a/eventarc-agentic-workflows/infra/main.tf b/eventarc-agentic-workflows/infra/main.tf index 23533ba..1187284 100644 --- a/eventarc-agentic-workflows/infra/main.tf +++ b/eventarc-agentic-workflows/infra/main.tf @@ -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 diff --git a/eventarc-agentic-workflows/main.tf b/eventarc-agentic-workflows/main.tf index db2f149..0c09c78 100644 --- a/eventarc-agentic-workflows/main.tf +++ b/eventarc-agentic-workflows/main.tf @@ -156,13 +156,7 @@ resource "terraform_data" "service_build_push" { provisioner "local-exec" { command = <