diff --git a/docs/src/content/docs/en/get_started/tutorials/dungeon-game/1.mdx b/docs/src/content/docs/en/get_started/tutorials/dungeon-game/1.mdx index e882572c4..3de4f7e6e 100644 --- a/docs/src/content/docs/en/get_started/tutorials/dungeon-game/1.mdx +++ b/docs/src/content/docs/en/get_started/tutorials/dungeon-game/1.mdx @@ -508,10 +508,9 @@ This is the entrypoint for the agent, configured as a FastAPI application compat ```ts // common/constructs/src/app/agents/story-agent.ts -import { Lazy, Names } from 'aws-cdk-lib'; +import { FileSystem, Lazy, Names } from 'aws-cdk-lib'; import { Platform } from 'aws-cdk-lib/aws-ecr-assets'; import { Construct } from 'constructs'; -import { execSync } from 'child_process'; import * as path from 'path'; import * as url from 'url'; import { @@ -520,6 +519,7 @@ import { Runtime, RuntimeProps, } from '@aws-cdk/aws-bedrock-agentcore-alpha'; +import { findWorkspaceRoot } from '../../../core/utils.js'; export type StoryAgentProps = Omit< RuntimeProps, @@ -533,14 +533,23 @@ export class StoryAgent extends Construct { constructor(scope: Construct, id: string, props?: StoryAgentProps) { super(scope, id); - this.dockerImage = AgentRuntimeArtifact.fromAsset( + const workspaceRoot = findWorkspaceRoot( path.dirname(url.fileURLToPath(new URL(import.meta.url))), + ); + + this.dockerImage = AgentRuntimeArtifact.fromAsset( + path.join(workspaceRoot, 'packages/dungeon-adventure/story/src/agent'), { platform: Platform.LINUX_ARM64, - extraHash: execSync( - `docker inspect dungeon-adventure-story-agent:latest --format '{{.Id}}'`, - { encoding: 'utf-8' }, - ).trim(), + buildContexts: { + workspace: workspaceRoot, + }, + extraHash: FileSystem.fingerprint( + path.join( + workspaceRoot, + 'dist/packages/dungeon-adventure/story/bundle/agent/story-agent', + ), + ), }, ); @@ -557,9 +566,7 @@ export class StoryAgent extends Construct { } ``` -This configures a CDK `AgentRuntimeArtifact` which uploads your agent Docker image to ECR, and hosts it using AgentCore Runtime. - -You may notice an extra `Dockerfile`, that references the Docker image from the `story` project, allowing us to co-locate the Dockerfile and agent source code. +This configures a CDK `AgentRuntimeArtifact` which uploads your agent Docker image to ECR, and hosts it using AgentCore Runtime. It uses CDK's `buildContexts` to reference the workspace root, allowing the Dockerfile to be co-located with the agent source code. diff --git a/docs/src/content/docs/en/guides/py-mcp-server.mdx b/docs/src/content/docs/en/guides/py-mcp-server.mdx index 83251fd43..c488ee4ce 100644 --- a/docs/src/content/docs/en/guides/py-mcp-server.mdx +++ b/docs/src/content/docs/en/guides/py-mcp-server.mdx @@ -149,7 +149,7 @@ A `docker` target specific to your MCP server is also added, which: - Builds a docker image from the `Dockerfile` which runs your MCP server on port `8000`, as per the [MCP protocol contract](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-service-contract.html#mcp-protocol-contract) :::tip -The docker image is built using a tag (for example `my-scope-my-project-mcp-server:latest`), which is referenced by your CDK or Terraform infrastructure, allowing for your `Dockerfile` to be co-located with your MCP server project. +Your `Dockerfile` is co-located with your MCP server project. For CDK, the construct uses `buildContexts` to build the image directly from this Dockerfile. For Terraform, the docker image is pre-built using a tag (for example `my-scope-my-project-mcp-server:latest`) which is referenced by your Terraform infrastructure. ::: ### Observability diff --git a/docs/src/content/docs/en/guides/py-strands-agent.mdx b/docs/src/content/docs/en/guides/py-strands-agent.mdx index d4c77d2a8..7ceab48cd 100644 --- a/docs/src/content/docs/en/guides/py-strands-agent.mdx +++ b/docs/src/content/docs/en/guides/py-strands-agent.mdx @@ -76,7 +76,6 @@ For deploying your Strands Agent, the following files are generated: - agents - \ - \.ts CDK construct for deploying your agent - - Dockerfile Passthrough docker file used by the CDK construct @@ -283,7 +282,7 @@ A `docker` target specific to your Strands Agent is also added, which: - Builds a docker image from the `Dockerfile` which runs your agent, as per the [AgentCore runtime contract](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-service-contract.html) :::tip -The docker image is built using a tag (for example `my-scope-my-project-agent:latest`), which is referenced by your CDK or Terraform infrastructure, allowing for your `Dockerfile` to be co-located with your Strands Agent project. +Your `Dockerfile` is co-located with your Strands Agent project. For CDK, the construct uses `buildContexts` to build the image directly from this Dockerfile. For Terraform, the docker image is pre-built using a tag (for example `my-scope-my-project-agent:latest`) which is referenced by your Terraform infrastructure. ::: ### Authentication diff --git a/docs/src/content/docs/en/guides/ts-mcp-server.mdx b/docs/src/content/docs/en/guides/ts-mcp-server.mdx index 19ca12ba7..459cebf37 100644 --- a/docs/src/content/docs/en/guides/ts-mcp-server.mdx +++ b/docs/src/content/docs/en/guides/ts-mcp-server.mdx @@ -153,7 +153,7 @@ The bundle target uses `http.ts` as the entrypoint for the Streamable HTTP MCP s The generator configures a `-docker` target which runs the bundled Streamable HTTP MCP server on port `8000` as per the [MCP protocol contract](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-service-contract.html#mcp-protocol-contract). :::tip -The docker image is built using a tag (for example `my-scope-my-project-mcp-server:latest`), which the CDK construct's `Dockerfile` inherits from, allowing for your `Dockerfile` to be co-located with your MCP server project. +Your `Dockerfile` is co-located with your MCP server project. For CDK, the construct uses `buildContexts` to build the image directly from this Dockerfile. For Terraform, the docker image is pre-built using a tag (for example `my-scope-my-project-mcp-server:latest`) which is referenced by your Terraform infrastructure. ::: A `docker` target is also generated which runs the docker build for all MCP servers if you have multiple defined. diff --git a/docs/src/content/docs/en/guides/ts-strands-agent.mdx b/docs/src/content/docs/en/guides/ts-strands-agent.mdx index 4afae9bc8..0a93f7916 100644 --- a/docs/src/content/docs/en/guides/ts-strands-agent.mdx +++ b/docs/src/content/docs/en/guides/ts-strands-agent.mdx @@ -78,7 +78,6 @@ For deploying your Strands Agent, the following files are generated: - agents - \ - \.ts CDK construct for deploying your agent - - Dockerfile Passthrough docker file used by the CDK construct @@ -207,7 +206,7 @@ The bundle target uses `index.ts` as the entrypoint for the WebSocket server to The generator configures a `-docker` target which runs the bundled WebSocket server on port `8080` as per the [AgentCore runtime contract](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-service-contract.html). :::tip -The docker image is built using a tag (for example `my-scope-my-project-agent:latest`), which is referenced by your CDK or Terraform infrastructure, allowing for your `Dockerfile` to be co-located with your Strands Agent project. +Your `Dockerfile` is co-located with your Strands Agent project. For CDK, the construct uses `buildContexts` to build the image directly from this Dockerfile. For Terraform, the docker image is pre-built using a tag (for example `my-scope-my-project-agent:latest`) which is referenced by your Terraform infrastructure. ::: A `docker` target is also generated which runs the docker build for all agents if you have multiple defined. diff --git a/docs/src/content/docs/en/snippets/mcp/shared-constructs.mdx b/docs/src/content/docs/en/snippets/mcp/shared-constructs.mdx index b323343c4..e4e0e59c1 100644 --- a/docs/src/content/docs/en/snippets/mcp/shared-constructs.mdx +++ b/docs/src/content/docs/en/snippets/mcp/shared-constructs.mdx @@ -14,7 +14,6 @@ For deploying your MCP Server, the following files are generated: - mcp-servers - \ - \.ts CDK construct for deploying your MCP Server - - Dockerfile Passthrough docker file used by the CDK construct diff --git a/docs/src/content/docs/es/get_started/tutorials/dungeon-game/1.mdx b/docs/src/content/docs/es/get_started/tutorials/dungeon-game/1.mdx index 8038227e2..81d85da49 100644 --- a/docs/src/content/docs/es/get_started/tutorials/dungeon-game/1.mdx +++ b/docs/src/content/docs/es/get_started/tutorials/dungeon-game/1.mdx @@ -508,10 +508,9 @@ Este es el punto de entrada para el agente, configurado como una aplicación Fas ```ts // common/constructs/src/app/agents/story-agent.ts -import { Lazy, Names } from 'aws-cdk-lib'; +import { FileSystem, Lazy, Names } from 'aws-cdk-lib'; import { Platform } from 'aws-cdk-lib/aws-ecr-assets'; import { Construct } from 'constructs'; -import { execSync } from 'child_process'; import * as path from 'path'; import * as url from 'url'; import { @@ -520,6 +519,7 @@ import { Runtime, RuntimeProps, } from '@aws-cdk/aws-bedrock-agentcore-alpha'; +import { findWorkspaceRoot } from '../../../core/utils.js'; export type StoryAgentProps = Omit< RuntimeProps, @@ -533,14 +533,23 @@ export class StoryAgent extends Construct { constructor(scope: Construct, id: string, props?: StoryAgentProps) { super(scope, id); - this.dockerImage = AgentRuntimeArtifact.fromAsset( + const workspaceRoot = findWorkspaceRoot( path.dirname(url.fileURLToPath(new URL(import.meta.url))), + ); + + this.dockerImage = AgentRuntimeArtifact.fromAsset( + path.join(workspaceRoot, 'packages/dungeon-adventure/story/src/agent'), { platform: Platform.LINUX_ARM64, - extraHash: execSync( - `docker inspect dungeon-adventure-story-agent:latest --format '{{.Id}}'`, - { encoding: 'utf-8' }, - ).trim(), + buildContexts: { + workspace: workspaceRoot, + }, + extraHash: FileSystem.fingerprint( + path.join( + workspaceRoot, + 'dist/packages/dungeon-adventure/story/bundle/agent/story-agent', + ), + ), }, ); @@ -557,9 +566,7 @@ export class StoryAgent extends Construct { } ``` -Esto configura un `AgentRuntimeArtifact` de CDK que sube tu imagen Docker del agente a ECR, y la aloja usando AgentCore Runtime. - -Puedes notar un `Dockerfile` adicional, que referencia la imagen Docker del proyecto `story`, permitiéndonos ubicar conjuntamente el Dockerfile y el código fuente del agente. +Esto configura un `AgentRuntimeArtifact` de CDK que sube tu imagen Docker del agente a ECR, y la aloja usando AgentCore Runtime. Utiliza `buildContexts` de CDK para referenciar la raíz del workspace, permitiendo que el Dockerfile esté ubicado conjuntamente con el código fuente del agente. diff --git a/docs/src/content/docs/es/guides/py-mcp-server.mdx b/docs/src/content/docs/es/guides/py-mcp-server.mdx index 478a48711..1b5e7b555 100644 --- a/docs/src/content/docs/es/guides/py-mcp-server.mdx +++ b/docs/src/content/docs/es/guides/py-mcp-server.mdx @@ -149,7 +149,7 @@ También se añade un objetivo `docker` específico para tu servidor MCP, que: - Construye una imagen Docker desde el `Dockerfile` que ejecuta tu servidor MCP en el puerto `8000`, según el [contrato de protocolo MCP](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-service-contract.html#mcp-protocol-contract) :::tip -La imagen Docker se construye usando una etiqueta (por ejemplo `my-scope-my-project-mcp-server:latest`), que es referenciada por tu infraestructura CDK o Terraform, permitiendo que tu `Dockerfile` esté ubicado junto a tu proyecto de servidor MCP. +Tu `Dockerfile` está ubicado junto a tu proyecto de servidor MCP. Para CDK, el construct usa `buildContexts` para construir la imagen directamente desde este Dockerfile. Para Terraform, la imagen Docker se construye previamente usando una etiqueta (por ejemplo `my-scope-my-project-mcp-server:latest`) que es referenciada por tu infraestructura Terraform. ::: ### Observabilidad diff --git a/docs/src/content/docs/es/guides/py-strands-agent.mdx b/docs/src/content/docs/es/guides/py-strands-agent.mdx index 8ef1b819c..9cad063b4 100644 --- a/docs/src/content/docs/es/guides/py-strands-agent.mdx +++ b/docs/src/content/docs/es/guides/py-strands-agent.mdx @@ -76,7 +76,6 @@ Para desplegar tu Agente Strands, se generan los siguientes archivos: - agents - \ - \.ts Constructo CDK para desplegar tu agente - - Dockerfile Archivo Docker usado por el constructo CDK @@ -281,7 +280,7 @@ También se añade un target `docker` específico que: - Construye una imagen Docker desde el `Dockerfile` que ejecuta tu agente según el [contrato de runtime de AgentCore](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-service-contract.html) :::tip -La imagen Docker se construye con un tag (ej. `my-scope-my-project-agent:latest`), referenciado por tu infraestructura CDK/Terraform, permitiendo co-localizar el `Dockerfile` con tu proyecto. +Tu `Dockerfile` está co-localizado con tu proyecto de Agente Strands. Para CDK, el constructo usa `buildContexts` para construir la imagen directamente desde este Dockerfile. Para Terraform, la imagen Docker se pre-construye usando un tag (por ejemplo `my-scope-my-project-agent:latest`) que es referenciado por tu infraestructura Terraform. ::: ### Autenticación @@ -462,8 +461,7 @@ Para autenticación IAM, la solicitud debe firmarse usando AWS Signature Version ```bash acurl bedrock-agentcore -N -X POST \ -'https://bedrock --agentcore..amazonaws.com/runtimes//invocations' \ +'https://bedrock-agentcore..amazonaws.com/runtimes//invocations' \ -d '{"prompt": "what is 3 + 5?", "session_id": "abcdefghijklmnopqrstuvwxyz0123456789"}' \ -H 'Content-Type: application/json' ``` @@ -477,8 +475,7 @@ acurl bedrock-agentcore -N -X POST \ Para autenticación Cognito, pasa el Access Token de Cognito en el header `Authorization`: ```bash -curl -N -X POST 'https://bedrock --agentcore..amazonaws.com/runtimes//invocations' \ +curl -N -X POST 'https://bedrock-agentcore..amazonaws.com/runtimes//invocations' \ -d '{"prompt": "what is 3 + 5?", "session_id": "abcdefghijklmnopqrstuvwxyz0123456789"}' \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " diff --git a/docs/src/content/docs/es/guides/ts-mcp-server.mdx b/docs/src/content/docs/es/guides/ts-mcp-server.mdx index 1661baec2..312ecb283 100644 --- a/docs/src/content/docs/es/guides/ts-mcp-server.mdx +++ b/docs/src/content/docs/es/guides/ts-mcp-server.mdx @@ -46,7 +46,7 @@ El generador añadirá los siguientes archivos a tu proyecto TypeScript existent - index.ts Exporta tu servidor - server.ts Definición principal del servidor - stdio.ts Punto de entrada para transporte STDIO, útil para servidores MCP locales simples - - http.ts Punto de entrada para transporte HTTP transmitible, útil para alojar tu servidor MCP + - http.ts Punto de entrada para transporte HTTP transmisible, útil para alojar tu servidor MCP - tools/ - divide.ts Herramienta de ejemplo - resources/ @@ -153,7 +153,7 @@ El objetivo bundle usa `http.ts` como punto de entrada para el servidor MCP HTTP El generador configura un objetivo `-docker` que ejecuta el servidor MCP HTTP transmisible empaquetado en el puerto `8000` según el [contrato de protocolo MCP](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-service-contract.html#mcp-protocol-contract). :::tip -La imagen docker se construye usando un tag (por ejemplo `my-scope-my-project-mcp-server:latest`), del cual hereda el `Dockerfile` del constructo CDK, permitiendo que tu `Dockerfile` esté ubicado junto a tu proyecto de servidor MCP. +Tu `Dockerfile` está ubicado junto a tu proyecto de servidor MCP. Para CDK, el constructo usa `buildContexts` para construir la imagen directamente desde este Dockerfile. Para Terraform, la imagen docker se pre-construye usando un tag (por ejemplo `my-scope-my-project-mcp-server:latest`) que es referenciado por tu infraestructura Terraform. ::: También se genera un objetivo `docker` que ejecuta la construcción docker para todos los servidores MCP si tienes múltiples definidos. diff --git a/docs/src/content/docs/es/guides/ts-strands-agent.mdx b/docs/src/content/docs/es/guides/ts-strands-agent.mdx index 40f415e1c..c07e5d3cb 100644 --- a/docs/src/content/docs/es/guides/ts-strands-agent.mdx +++ b/docs/src/content/docs/es/guides/ts-strands-agent.mdx @@ -78,7 +78,6 @@ Para desplegar tu Strands Agent, se generan los siguientes archivos: - agents - \ - \.ts Constructo CDK para desplegar tu agente - - Dockerfile Archivo docker de paso utilizado por el constructo CDK @@ -207,7 +206,7 @@ El target bundle usa `index.ts` como punto de entrada para el servidor WebSocket El generador configura un target `-docker` que ejecuta el servidor WebSocket empaquetado en el puerto `8080` según el [contrato de runtime de AgentCore](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-service-contract.html). :::tip -La imagen docker se construye usando una etiqueta (por ejemplo `my-scope-my-project-agent:latest`), que es referenciada por tu infraestructura CDK o Terraform, permitiendo que tu `Dockerfile` esté co-ubicado con tu proyecto Strands Agent. +Tu `Dockerfile` está co-ubicado con tu proyecto Strands Agent. Para CDK, el constructo usa `buildContexts` para construir la imagen directamente desde este Dockerfile. Para Terraform, la imagen docker se pre-construye usando una etiqueta (por ejemplo `my-scope-my-project-agent:latest`) que es referenciada por tu infraestructura Terraform. ::: También se genera un target `docker` que ejecuta la construcción docker para todos los agentes si tienes múltiples definidos. diff --git a/docs/src/content/docs/es/snippets/mcp/shared-constructs.mdx b/docs/src/content/docs/es/snippets/mcp/shared-constructs.mdx index a47793eb1..d5a2ed455 100644 --- a/docs/src/content/docs/es/snippets/mcp/shared-constructs.mdx +++ b/docs/src/content/docs/es/snippets/mcp/shared-constructs.mdx @@ -15,7 +15,6 @@ Para implementar tu MCP Server, se generan los siguientes archivos: - mcp-servers - \ - \.ts Constructo CDK para implementar tu MCP Server - - Dockerfile Archivo Docker passthrough utilizado por el constructo CDK diff --git a/docs/src/content/docs/fr/get_started/tutorials/dungeon-game/1.mdx b/docs/src/content/docs/fr/get_started/tutorials/dungeon-game/1.mdx index ed917abcd..579da22b0 100644 --- a/docs/src/content/docs/fr/get_started/tutorials/dungeon-game/1.mdx +++ b/docs/src/content/docs/fr/get_started/tutorials/dungeon-game/1.mdx @@ -509,10 +509,9 @@ C'est le point d'entrée de l'agent, configuré comme une application FastAPI co ```ts // common/constructs/src/app/agents/story-agent.ts -import { Lazy, Names } from 'aws-cdk-lib'; +import { FileSystem, Lazy, Names } from 'aws-cdk-lib'; import { Platform } from 'aws-cdk-lib/aws-ecr-assets'; import { Construct } from 'constructs'; -import { execSync } from 'child_process'; import * as path from 'path'; import * as url from 'url'; import { @@ -521,6 +520,7 @@ import { Runtime, RuntimeProps, } from '@aws-cdk/aws-bedrock-agentcore-alpha'; +import { findWorkspaceRoot } from '../../../core/utils.js'; export type StoryAgentProps = Omit< RuntimeProps, @@ -534,14 +534,23 @@ export class StoryAgent extends Construct { constructor(scope: Construct, id: string, props?: StoryAgentProps) { super(scope, id); - this.dockerImage = AgentRuntimeArtifact.fromAsset( + const workspaceRoot = findWorkspaceRoot( path.dirname(url.fileURLToPath(new URL(import.meta.url))), + ); + + this.dockerImage = AgentRuntimeArtifact.fromAsset( + path.join(workspaceRoot, 'packages/dungeon-adventure/story/src/agent'), { platform: Platform.LINUX_ARM64, - extraHash: execSync( - `docker inspect dungeon-adventure-story-agent:latest --format '{{.Id}}'`, - { encoding: 'utf-8' }, - ).trim(), + buildContexts: { + workspace: workspaceRoot, + }, + extraHash: FileSystem.fingerprint( + path.join( + workspaceRoot, + 'dist/packages/dungeon-adventure/story/bundle/agent/story-agent', + ), + ), }, ); @@ -558,9 +567,7 @@ export class StoryAgent extends Construct { } ``` -Cela configure un `AgentRuntimeArtifact` CDK qui télécharge votre image Docker d'agent vers ECR et l'héberge en utilisant AgentCore Runtime. - -Vous remarquerez peut-être un `Dockerfile` supplémentaire qui référence l'image Docker du projet `story`, nous permettant de co-localiser le Dockerfile et le code source de l'agent. +Cela configure un `AgentRuntimeArtifact` CDK qui télécharge votre image Docker d'agent vers ECR et l'héberge en utilisant AgentCore Runtime. Il utilise `buildContexts` de CDK pour référencer la racine du workspace, permettant au Dockerfile d'être co-localisé avec le code source de l'agent. diff --git a/docs/src/content/docs/fr/guides/py-mcp-server.mdx b/docs/src/content/docs/fr/guides/py-mcp-server.mdx index 296079ea7..33026ad83 100644 --- a/docs/src/content/docs/fr/guides/py-mcp-server.mdx +++ b/docs/src/content/docs/fr/guides/py-mcp-server.mdx @@ -149,7 +149,7 @@ Une cible `docker` spécifique à votre serveur MCP est aussi ajoutée. Elle : - Construit une image Docker depuis le `Dockerfile` exécutant votre serveur MCP sur le port `8000`, conformément au [contrat de service MCP](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-service-contract.html#mcp-protocol-contract) :::tip -L'image Docker est construite avec un tag (ex: `my-scope-my-project-mcp-server:latest`), référencé par votre infrastructure CDK/Terraform, permettant à votre `Dockerfile` de rester colocalisé avec votre projet de serveur MCP. +Votre `Dockerfile` reste colocalisé avec votre projet de serveur MCP. Pour CDK, le construct utilise `buildContexts` pour construire l'image directement depuis ce Dockerfile. Pour Terraform, l'image Docker est pré-construite avec un tag (par exemple `my-scope-my-project-mcp-server:latest`) qui est référencé par votre infrastructure Terraform. ::: ### Observabilité diff --git a/docs/src/content/docs/fr/guides/py-strands-agent.mdx b/docs/src/content/docs/fr/guides/py-strands-agent.mdx index 7203b6bf3..9cde51a9a 100644 --- a/docs/src/content/docs/fr/guides/py-strands-agent.mdx +++ b/docs/src/content/docs/fr/guides/py-strands-agent.mdx @@ -76,7 +76,6 @@ Pour le déploiement de votre agent Strands, les fichiers suivants sont génér - agents - \ - \.ts Construct CDK pour déployer votre agent - - Dockerfile Fichier Docker transmis utilisé par le construct CDK @@ -283,7 +282,7 @@ Une cible `docker` spécifique à votre agent Strands est également ajoutée, q - Construit une image Docker depuis le `Dockerfile` exécutant votre agent, conformément au [contrat runtime AgentCore](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-service-contract.html) :::tip -L'image Docker est construite avec un tag (ex: `my-scope-my-project-agent:latest`), référencé par votre infrastructure CDK ou Terraform, permettant à votre `Dockerfile` d'être co-localisé avec votre projet d'agent Strands. +Votre `Dockerfile` est co-localisé avec votre projet d'agent Strands. Pour CDK, le construct utilise `buildContexts` pour construire l'image directement depuis ce Dockerfile. Pour Terraform, l'image Docker est pré-construite avec un tag (par exemple `my-scope-my-project-agent:latest`) référencé par votre infrastructure Terraform. ::: ### Authentification diff --git a/docs/src/content/docs/fr/guides/ts-mcp-server.mdx b/docs/src/content/docs/fr/guides/ts-mcp-server.mdx index 9ac39d0fe..439fc8432 100644 --- a/docs/src/content/docs/fr/guides/ts-mcp-server.mdx +++ b/docs/src/content/docs/fr/guides/ts-mcp-server.mdx @@ -153,7 +153,7 @@ La cible de bundle utilise `http.ts` comme point d'entrée pour le serveur MCP H Le générateur configure une cible `-docker` qui exécute le serveur MCP HTTP Streamable bundle sur le port `8000` conformément au [contrat de protocole MCP](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-service-contract.html#mcp-protocol-contract). :::tip -L'image Docker est construite avec un tag (par exemple `my-scope-my-project-mcp-server:latest`), dont le `Dockerfile` du construct CDK hérite, permettant à votre `Dockerfile` d'être co-localisé avec votre projet de serveur MCP. +Votre `Dockerfile` est co-localisé avec votre projet de serveur MCP. Pour CDK, le construct utilise `buildContexts` pour construire l'image directement depuis ce Dockerfile. Pour Terraform, l'image Docker est pré-construite avec un tag (par exemple `my-scope-my-project-mcp-server:latest`) qui est référencé par votre infrastructure Terraform. ::: Une cible `docker` est aussi générée pour construire toutes les images Docker si vous avez plusieurs serveurs MCP définis. diff --git a/docs/src/content/docs/fr/guides/ts-strands-agent.mdx b/docs/src/content/docs/fr/guides/ts-strands-agent.mdx index 65ab26303..33d17d55c 100644 --- a/docs/src/content/docs/fr/guides/ts-strands-agent.mdx +++ b/docs/src/content/docs/fr/guides/ts-strands-agent.mdx @@ -78,7 +78,6 @@ Pour déployer votre Strands Agent, les fichiers suivants sont générés : - agents - \ - \.ts Construct CDK pour déployer votre agent - - Dockerfile Fichier docker passthrough utilisé par le construct CDK @@ -207,7 +206,7 @@ La cible bundle utilise `index.ts` comme point d'entrée pour le serveur WebSock Le générateur configure une cible `-docker` qui exécute le serveur WebSocket groupé sur le port `8080` conformément au [contrat de runtime AgentCore](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-service-contract.html). :::tip -L'image docker est construite en utilisant un tag (par exemple `my-scope-my-project-agent:latest`), qui est référencé par votre infrastructure CDK ou Terraform, permettant à votre `Dockerfile` d'être colocalisé avec votre projet Strands Agent. +Votre `Dockerfile` est colocalisé avec votre projet Strands Agent. Pour CDK, le construct utilise `buildContexts` pour construire l'image directement depuis ce Dockerfile. Pour Terraform, l'image docker est pré-construite en utilisant un tag (par exemple `my-scope-my-project-agent:latest`) qui est référencé par votre infrastructure Terraform. ::: Une cible `docker` est également générée qui exécute la construction docker pour tous les agents si vous en avez plusieurs définis. diff --git a/docs/src/content/docs/fr/snippets/mcp/shared-constructs.mdx b/docs/src/content/docs/fr/snippets/mcp/shared-constructs.mdx index 764ae7379..b50b88875 100644 --- a/docs/src/content/docs/fr/snippets/mcp/shared-constructs.mdx +++ b/docs/src/content/docs/fr/snippets/mcp/shared-constructs.mdx @@ -15,7 +15,6 @@ Pour le déploiement de votre serveur MCP, les fichiers suivants sont générés - mcp-servers - \ - \.ts Construct CDK pour déployer votre serveur MCP - - Dockerfile Fichier Docker transmis directement utilisé par le construct CDK diff --git a/docs/src/content/docs/it/get_started/tutorials/dungeon-game/1.mdx b/docs/src/content/docs/it/get_started/tutorials/dungeon-game/1.mdx index 3dffe1289..e5e9cb96d 100644 --- a/docs/src/content/docs/it/get_started/tutorials/dungeon-game/1.mdx +++ b/docs/src/content/docs/it/get_started/tutorials/dungeon-game/1.mdx @@ -508,10 +508,9 @@ Questo è l'entrypoint dell'agente, configurato come applicazione FastAPI compat ```ts // common/constructs/src/app/agents/story-agent.ts -import { Lazy, Names } from 'aws-cdk-lib'; +import { FileSystem, Lazy, Names } from 'aws-cdk-lib'; import { Platform } from 'aws-cdk-lib/aws-ecr-assets'; import { Construct } from 'constructs'; -import { execSync } from 'child_process'; import * as path from 'path'; import * as url from 'url'; import { @@ -520,6 +519,7 @@ import { Runtime, RuntimeProps, } from '@aws-cdk/aws-bedrock-agentcore-alpha'; +import { findWorkspaceRoot } from '../../../core/utils.js'; export type StoryAgentProps = Omit< RuntimeProps, @@ -533,14 +533,23 @@ export class StoryAgent extends Construct { constructor(scope: Construct, id: string, props?: StoryAgentProps) { super(scope, id); - this.dockerImage = AgentRuntimeArtifact.fromAsset( + const workspaceRoot = findWorkspaceRoot( path.dirname(url.fileURLToPath(new URL(import.meta.url))), + ); + + this.dockerImage = AgentRuntimeArtifact.fromAsset( + path.join(workspaceRoot, 'packages/dungeon-adventure/story/src/agent'), { platform: Platform.LINUX_ARM64, - extraHash: execSync( - `docker inspect dungeon-adventure-story-agent:latest --format '{{.Id}}'`, - { encoding: 'utf-8' }, - ).trim(), + buildContexts: { + workspace: workspaceRoot, + }, + extraHash: FileSystem.fingerprint( + path.join( + workspaceRoot, + 'dist/packages/dungeon-adventure/story/bundle/agent/story-agent', + ), + ), }, ); @@ -557,9 +566,7 @@ export class StoryAgent extends Construct { } ``` -Questo configura un `AgentRuntimeArtifact` CDK che carica l'immagine Docker dell'agente su ECR e la ospita usando AgentCore Runtime. - -Potresti notare un `Dockerfile` aggiuntivo che referenzia l'immagine Docker dal progetto `story`, permettendo di collocare Dockerfile e codice sorgente insieme. +Questo configura un `AgentRuntimeArtifact` CDK che carica l'immagine Docker dell'agente su ECR e la ospita usando AgentCore Runtime. Utilizza i `buildContexts` di CDK per referenziare la radice del workspace, permettendo al Dockerfile di essere collocato insieme al codice sorgente dell'agente. diff --git a/docs/src/content/docs/it/guides/py-mcp-server.mdx b/docs/src/content/docs/it/guides/py-mcp-server.mdx index f841fb142..927f7db58 100644 --- a/docs/src/content/docs/it/guides/py-mcp-server.mdx +++ b/docs/src/content/docs/it/guides/py-mcp-server.mdx @@ -147,7 +147,7 @@ Viene anche aggiunto un target `docker` specifico per il tuo server MCP che: - Costruisce un'immagine docker dal `Dockerfile` che esegue il server MCP sulla porta `8000`, secondo il [contratto di servizio MCP](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-service-contract.html#mcp-protocol-contract) :::tip -L'immagine docker è costruita usando un tag (esempio `my-scope-my-project-mcp-server:latest`), referenziato dalla tua infrastruttura CDK o Terraform, permettendo al tuo `Dockerfile` di rimanere co-locato con il progetto del server MCP. +Il tuo `Dockerfile` è co-locato con il progetto del server MCP. Per CDK, il costrutto usa `buildContexts` per costruire l'immagine direttamente da questo Dockerfile. Per Terraform, l'immagine docker è pre-costruita usando un tag (esempio `my-scope-my-project-mcp-server:latest`) che viene referenziato dalla tua infrastruttura Terraform. ::: ### Osservabilità diff --git a/docs/src/content/docs/it/guides/py-strands-agent.mdx b/docs/src/content/docs/it/guides/py-strands-agent.mdx index 638cd7ece..6b13f00b2 100644 --- a/docs/src/content/docs/it/guides/py-strands-agent.mdx +++ b/docs/src/content/docs/it/guides/py-strands-agent.mdx @@ -76,7 +76,6 @@ Per la distribuzione del tuo Strands Agent, vengono generati i seguenti file: - agents - \ - \.ts Costrutto CDK per distribuire l'agente - - Dockerfile File Docker pass-through usato dal costrutto CDK @@ -283,7 +282,7 @@ Viene anche aggiunto un target `docker` specifico per il tuo Strands Agent, che: - Costruisce un'immagine docker dal `Dockerfile` che esegue il tuo agente, secondo il [contratto runtime di AgentCore](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-service-contract.html) :::tip -L'immagine docker è costruita usando un tag (ad esempio `my-scope-my-project-agent:latest`), referenziato dalla tua infrastruttura CDK o Terraform, permettendo al tuo `Dockerfile` di essere co-locato con il progetto Strands Agent. +Il tuo `Dockerfile` è co-locato con il progetto Strands Agent. Per CDK, il costrutto utilizza `buildContexts` per costruire l'immagine direttamente da questo Dockerfile. Per Terraform, l'immagine docker è pre-costruita usando un tag (ad esempio `my-scope-my-project-agent:latest`) che viene referenziato dalla tua infrastruttura Terraform. ::: ### Autenticazione diff --git a/docs/src/content/docs/it/guides/ts-mcp-server.mdx b/docs/src/content/docs/it/guides/ts-mcp-server.mdx index d692d14c5..7ac341740 100644 --- a/docs/src/content/docs/it/guides/ts-mcp-server.mdx +++ b/docs/src/content/docs/it/guides/ts-mcp-server.mdx @@ -153,7 +153,7 @@ Il target bundle usa `http.ts` come entrypoint per il server MCP HTTP Streamable Il generatore configura un target `-docker` che esegue il server MCP HTTP Streamable bundled sulla porta `8000` secondo il [contratto di servizio MCP](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-service-contract.html#mcp-protocol-contract). :::tip -L'immagine Docker è costruita usando un tag (es. `my-scope-my-project-mcp-server:latest`), da cui eredita il `Dockerfile` del costrutto CDK, permettendo al tuo `Dockerfile` di essere co-locato con il progetto del server MCP. +Il tuo `Dockerfile` è co-locato con il progetto del server MCP. Per CDK, il costrutto usa `buildContexts` per costruire l'immagine direttamente da questo Dockerfile. Per Terraform, l'immagine Docker è pre-costruita usando un tag (ad esempio `my-scope-my-project-mcp-server:latest`) a cui fa riferimento la tua infrastruttura Terraform. ::: Viene generato anche un target `docker` che esegue il build Docker per tutti i server MCP se ne sono definiti multipli. diff --git a/docs/src/content/docs/it/guides/ts-strands-agent.mdx b/docs/src/content/docs/it/guides/ts-strands-agent.mdx index dfe5f3d7f..c44abfff9 100644 --- a/docs/src/content/docs/it/guides/ts-strands-agent.mdx +++ b/docs/src/content/docs/it/guides/ts-strands-agent.mdx @@ -78,7 +78,6 @@ Per distribuire il tuo Strands Agent, vengono generati i seguenti file: - agents - \ - \.ts Costrutto CDK per distribuire il tuo agente - - Dockerfile File docker passthrough utilizzato dal costrutto CDK @@ -207,7 +206,7 @@ Il target bundle utilizza `index.ts` come punto di ingresso per il server WebSoc Il generatore configura un target `-docker` che esegue il server WebSocket in bundle sulla porta `8080` come da [contratto runtime di AgentCore](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-service-contract.html). :::tip -L'immagine docker viene creata utilizzando un tag (ad esempio `my-scope-my-project-agent:latest`), a cui fa riferimento la tua infrastruttura CDK o Terraform, consentendo al tuo `Dockerfile` di essere co-localizzato con il tuo progetto Strands Agent. +Il tuo `Dockerfile` è co-localizzato con il tuo progetto Strands Agent. Per CDK, il costrutto utilizza `buildContexts` per creare l'immagine direttamente da questo Dockerfile. Per Terraform, l'immagine docker viene pre-creata utilizzando un tag (ad esempio `my-scope-my-project-agent:latest`) a cui fa riferimento la tua infrastruttura Terraform. ::: Viene generato anche un target `docker` che esegue la build docker per tutti gli agenti se ne hai definiti più di uno. diff --git a/docs/src/content/docs/it/snippets/mcp/shared-constructs.mdx b/docs/src/content/docs/it/snippets/mcp/shared-constructs.mdx index 81f683180..e8808c42d 100644 --- a/docs/src/content/docs/it/snippets/mcp/shared-constructs.mdx +++ b/docs/src/content/docs/it/snippets/mcp/shared-constructs.mdx @@ -15,7 +15,6 @@ Per il deployment del tuo MCP Server, vengono generati i seguenti file: - mcp-servers - \ - \.ts Costrutto CDK per il deployment del tuo MCP Server - - Dockerfile File Docker passthrough utilizzato dal costrutto CDK diff --git a/docs/src/content/docs/jp/get_started/tutorials/dungeon-game/1.mdx b/docs/src/content/docs/jp/get_started/tutorials/dungeon-game/1.mdx index b51d92939..c057c2e4e 100644 --- a/docs/src/content/docs/jp/get_started/tutorials/dungeon-game/1.mdx +++ b/docs/src/content/docs/jp/get_started/tutorials/dungeon-game/1.mdx @@ -508,10 +508,9 @@ if __name__ == "__main__": ```ts // common/constructs/src/app/agents/story-agent.ts -import { Lazy, Names } from 'aws-cdk-lib'; +import { FileSystem, Lazy, Names } from 'aws-cdk-lib'; import { Platform } from 'aws-cdk-lib/aws-ecr-assets'; import { Construct } from 'constructs'; -import { execSync } from 'child_process'; import * as path from 'path'; import * as url from 'url'; import { @@ -520,6 +519,7 @@ import { Runtime, RuntimeProps, } from '@aws-cdk/aws-bedrock-agentcore-alpha'; +import { findWorkspaceRoot } from '../../../core/utils.js'; export type StoryAgentProps = Omit< RuntimeProps, @@ -533,14 +533,23 @@ export class StoryAgent extends Construct { constructor(scope: Construct, id: string, props?: StoryAgentProps) { super(scope, id); - this.dockerImage = AgentRuntimeArtifact.fromAsset( + const workspaceRoot = findWorkspaceRoot( path.dirname(url.fileURLToPath(new URL(import.meta.url))), + ); + + this.dockerImage = AgentRuntimeArtifact.fromAsset( + path.join(workspaceRoot, 'packages/dungeon-adventure/story/src/agent'), { platform: Platform.LINUX_ARM64, - extraHash: execSync( - `docker inspect dungeon-adventure-story-agent:latest --format '{{.Id}}'`, - { encoding: 'utf-8' }, - ).trim(), + buildContexts: { + workspace: workspaceRoot, + }, + extraHash: FileSystem.fingerprint( + path.join( + workspaceRoot, + 'dist/packages/dungeon-adventure/story/bundle/agent/story-agent', + ), + ), }, ); @@ -557,9 +566,7 @@ export class StoryAgent extends Construct { } ``` -これは、エージェントDockerイメージをECRにアップロードし、AgentCore Runtimeを使用してホストするCDK `AgentRuntimeArtifact`を設定します。 - -追加の`Dockerfile`に気付くかもしれませんが、これは`story`プロジェクトからDockerイメージを参照し、Dockerfileとエージェントソースコードを同じ場所に配置できるようにします。 +これは、エージェントDockerイメージをECRにアップロードし、AgentCore Runtimeを使用してホストするCDK `AgentRuntimeArtifact`を設定します。CDKの`buildContexts`を使用してワークスペースルートを参照し、Dockerfileをエージェントソースコードと同じ場所に配置できるようにします。 diff --git a/docs/src/content/docs/jp/guides/py-mcp-server.mdx b/docs/src/content/docs/jp/guides/py-mcp-server.mdx index 695e4873c..b49514136 100644 --- a/docs/src/content/docs/jp/guides/py-mcp-server.mdx +++ b/docs/src/content/docs/jp/guides/py-mcp-server.mdx @@ -149,7 +149,7 @@ Bedrock AgentCore Runtime向けにMCPサーバーをビルドするため、プ - [MCPプロトコル契約](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-service-contract.html#mcp-protocol-contract)に従いポート`8000`で動作するDockerイメージをビルド :::tip -Dockerイメージはタグ(例:`my-scope-my-project-mcp-server:latest`)でビルドされ、CDKやTerraformインフラから参照されます。これによりDockerfileをMCPサーバープロジェクトと同じ場所に配置できます。 +`Dockerfile`はMCPサーバープロジェクトと同じ場所に配置されます。CDKの場合、コンストラクトは`buildContexts`を使用してこのDockerfileから直接イメージをビルドします。Terraformの場合、Dockerイメージはタグ(例:`my-scope-my-project-mcp-server:latest`)を使用して事前ビルドされ、Terraformインフラから参照されます。 ::: ### オブザーバビリティ diff --git a/docs/src/content/docs/jp/guides/py-strands-agent.mdx b/docs/src/content/docs/jp/guides/py-strands-agent.mdx index 8bece4060..b403e56d1 100644 --- a/docs/src/content/docs/jp/guides/py-strands-agent.mdx +++ b/docs/src/content/docs/jp/guides/py-strands-agent.mdx @@ -53,7 +53,7 @@ AIエージェントをツール付きで構築するためのPython [Strands Ag - init.py CORSとエラーハンドリングミドルウェアを備えたFastAPIアプリケーション設定 - agent.py サンプルツール付きメインエージェント定義 - main.py Bedrock AgentCore Runtime用エントリーポイント - - Dockerfile エージェントホスティング用Dockerfile(`computeType`が`None`の場合は生成されない) + - Dockerfile エージェントホスティング用Dockerfile(`computeType`が`None`の場合は除外) - pyproject.toml Strands依存関係が追加された設定ファイル - project.json エージェントサーブターゲットが追加された設定ファイル @@ -76,7 +76,6 @@ Strandsエージェントのデプロイ用に以下のファイルが生成さ - agents - \ - \.ts エージェントデプロイ用CDKコンストラクト - - Dockerfile CDKコンストラクトで使用されるDockerfile @@ -85,7 +84,7 @@ Strandsエージェントのデプロイ用に以下のファイルが生成さ - app - agents - \ - - \.tf エージェントデプロイ用Terraformモジュール + - \.tf エージェントデプロイ用モジュール - core - agent-core - runtime.tf Bedrock AgentCore Runtimeデプロイ用汎用モジュール @@ -281,7 +280,7 @@ Strandsエージェント固有の`docker`ターゲットも追加されます - [AgentCore runtime契約](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-service-contract.html)に従ってエージェントを実行する`Dockerfile`からDockerイメージをビルド :::tip -Dockerイメージはタグ(例:`my-scope-my-project-agent:latest`)を使用してビルドされ、CDK/Terraformインフラストラクチャで参照されるため、`Dockerfile`をStrandsエージェントプロジェクトと同じ場所に配置できます。 +`Dockerfile`はStrandsエージェントプロジェクトと同じ場所に配置されます。CDKの場合、コンストラクトは`buildContexts`を使用してこのDockerfileから直接イメージをビルドします。Terraformの場合、Dockerイメージはタグ(例:`my-scope-my-project-agent:latest`)を使用して事前にビルドされ、Terraformインフラストラクチャで参照されます。 ::: ### 認証 diff --git a/docs/src/content/docs/jp/guides/ts-mcp-server.mdx b/docs/src/content/docs/jp/guides/ts-mcp-server.mdx index ef2da1f2f..d144d8c8c 100644 --- a/docs/src/content/docs/jp/guides/ts-mcp-server.mdx +++ b/docs/src/content/docs/jp/guides/ts-mcp-server.mdx @@ -153,7 +153,7 @@ MCPサーバーをテストする最も簡単な方法は、インスペクタ ジェネレータは`-docker`ターゲットを設定し、[MCPプロトコル契約](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-service-contract.html#mcp-protocol-contract)に従ってポート`8000`でバンドルされたストリーミングHTTP MCPサーバーを実行します。 :::tip -Dockerイメージはタグ(例:`my-scope-my-project-mcp-server:latest`)を使用してビルドされ、CDKコンストラクトの`Dockerfile`はこれを継承します。これによりMCPサーバープロジェクトとDockerfileを同じ場所に配置できます。 +`Dockerfile`はMCPサーバープロジェクトと同じ場所に配置されます。CDKの場合、コンストラクトは`buildContexts`を使用してこのDockerfileから直接イメージをビルドします。Terraformの場合、dockerイメージはタグ(例:`my-scope-my-project-mcp-server:latest`)を使用して事前にビルドされ、Terraformインフラストラクチャから参照されます。 ::: 複数のMCPサーバーを定義している場合、すべてのMCPサーバーのdockerビルドを実行する`docker`ターゲットも生成されます。 diff --git a/docs/src/content/docs/jp/guides/ts-strands-agent.mdx b/docs/src/content/docs/jp/guides/ts-strands-agent.mdx index 1b3fb3cad..313e96e40 100644 --- a/docs/src/content/docs/jp/guides/ts-strands-agent.mdx +++ b/docs/src/content/docs/jp/guides/ts-strands-agent.mdx @@ -78,7 +78,6 @@ Strands Agent をデプロイするために、次のファイルが生成され - agents - \ - \.ts エージェントをデプロイするための CDK コンストラクト - - Dockerfile CDK コンストラクトで使用されるパススルー docker ファイル @@ -207,7 +206,7 @@ bundle ターゲットは、Bedrock AgentCore Runtime でホストする WebSock ジェネレーターは `-docker` ターゲットを設定し、[AgentCore ランタイムコントラクト](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-service-contract.html)に従ってポート `8080` でバンドルされた WebSocket サーバーを実行します。 :::tip -docker イメージはタグ (例: `my-scope-my-project-agent:latest`) を使用してビルドされ、CDK または Terraform インフラストラクチャから参照されるため、`Dockerfile` を Strands Agent プロジェクトと同じ場所に配置できます。 +`Dockerfile` は Strands Agent プロジェクトと同じ場所に配置されます。CDK の場合、コンストラクトは `buildContexts` を使用してこの Dockerfile から直接イメージをビルドします。Terraform の場合、docker イメージはタグ (例: `my-scope-my-project-agent:latest`) を使用して事前にビルドされ、Terraform インフラストラクチャから参照されます。 ::: 複数のエージェントが定義されている場合、すべてのエージェントに対して docker ビルドを実行する `docker` ターゲットも生成されます。 diff --git a/docs/src/content/docs/jp/snippets/mcp/shared-constructs.mdx b/docs/src/content/docs/jp/snippets/mcp/shared-constructs.mdx index b86554298..74cd66d9b 100644 --- a/docs/src/content/docs/jp/snippets/mcp/shared-constructs.mdx +++ b/docs/src/content/docs/jp/snippets/mcp/shared-constructs.mdx @@ -15,7 +15,6 @@ MCP サーバーをデプロイするために、以下のファイルが生成 - mcp-servers - \ - \.ts MCP サーバーをデプロイするための CDK コンストラクト - - Dockerfile CDK コンストラクトで使用されるパススルー Dockerfile diff --git a/docs/src/content/docs/ko/get_started/tutorials/dungeon-game/1.mdx b/docs/src/content/docs/ko/get_started/tutorials/dungeon-game/1.mdx index ba226edf7..48a2d52a4 100644 --- a/docs/src/content/docs/ko/get_started/tutorials/dungeon-game/1.mdx +++ b/docs/src/content/docs/ko/get_started/tutorials/dungeon-game/1.mdx @@ -505,10 +505,9 @@ if __name__ == "__main__": ```ts // common/constructs/src/app/agents/story-agent.ts -import { Lazy, Names } from 'aws-cdk-lib'; +import { FileSystem, Lazy, Names } from 'aws-cdk-lib'; import { Platform } from 'aws-cdk-lib/aws-ecr-assets'; import { Construct } from 'constructs'; -import { execSync } from 'child_process'; import * as path from 'path'; import * as url from 'url'; import { @@ -517,6 +516,7 @@ import { Runtime, RuntimeProps, } from '@aws-cdk/aws-bedrock-agentcore-alpha'; +import { findWorkspaceRoot } from '../../../core/utils.js'; export type StoryAgentProps = Omit< RuntimeProps, @@ -530,14 +530,23 @@ export class StoryAgent extends Construct { constructor(scope: Construct, id: string, props?: StoryAgentProps) { super(scope, id); - this.dockerImage = AgentRuntimeArtifact.fromAsset( + const workspaceRoot = findWorkspaceRoot( path.dirname(url.fileURLToPath(new URL(import.meta.url))), + ); + + this.dockerImage = AgentRuntimeArtifact.fromAsset( + path.join(workspaceRoot, 'packages/dungeon-adventure/story/src/agent'), { platform: Platform.LINUX_ARM64, - extraHash: execSync( - `docker inspect dungeon-adventure-story-agent:latest --format '{{.Id}}'`, - { encoding: 'utf-8' }, - ).trim(), + buildContexts: { + workspace: workspaceRoot, + }, + extraHash: FileSystem.fingerprint( + path.join( + workspaceRoot, + 'dist/packages/dungeon-adventure/story/bundle/agent/story-agent', + ), + ), }, ); @@ -554,9 +563,7 @@ export class StoryAgent extends Construct { } ``` -이 코드는 ECR에 에이전트 Docker 이미지를 업로드하고 AgentCore 런타임을 사용하여 호스팅하는 CDK `AgentRuntimeArtifact`를 구성합니다. - -추가 `Dockerfile`이 있는데, 이는 `story` 프로젝트의 Docker 이미지를 참조하여 Dockerfile과 에이전트 소스 코드를 함께 위치시킬 수 있도록 합니다. +이 코드는 ECR에 에이전트 Docker 이미지를 업로드하고 AgentCore 런타임을 사용하여 호스팅하는 CDK `AgentRuntimeArtifact`를 구성합니다. CDK의 `buildContexts`를 사용하여 워크스페이스 루트를 참조하므로 Dockerfile을 에이전트 소스 코드와 함께 위치시킬 수 있습니다. diff --git a/docs/src/content/docs/ko/guides/py-mcp-server.mdx b/docs/src/content/docs/ko/guides/py-mcp-server.mdx index d9ee93fe2..d8c336491 100644 --- a/docs/src/content/docs/ko/guides/py-mcp-server.mdx +++ b/docs/src/content/docs/ko/guides/py-mcp-server.mdx @@ -149,7 +149,7 @@ Bedrock AgentCore 런타임용 MCP 서버 빌드를 위해 프로젝트에 `bund - `Dockerfile`에서 포트 `8000`으로 MCP 서버를 실행하는 도커 이미지 빌드 ([MCP 프로토콜 계약](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-service-contract.html#mcp-protocol-contract) 준수) :::tip -도커 이미지는 태그(예: `my-scope-my-project-mcp-server:latest`)로 빌드되며, 이는 CDK나 Terraform 인프라에서 참조되어 MCP 서버 프로젝트와 동일 위치에 Dockerfile을 유지할 수 있게 합니다. +`Dockerfile`은 MCP 서버 프로젝트와 동일 위치에 있습니다. CDK의 경우 construct가 `buildContexts`를 사용하여 이 Dockerfile에서 직접 이미지를 빌드합니다. Terraform의 경우 도커 이미지가 태그(예: `my-scope-my-project-mcp-server:latest`)로 사전 빌드되며, 이는 Terraform 인프라에서 참조됩니다. ::: ### 관측성 diff --git a/docs/src/content/docs/ko/guides/py-strands-agent.mdx b/docs/src/content/docs/ko/guides/py-strands-agent.mdx index 5344ec284..f9e97f082 100644 --- a/docs/src/content/docs/ko/guides/py-strands-agent.mdx +++ b/docs/src/content/docs/ko/guides/py-strands-agent.mdx @@ -76,7 +76,6 @@ Strands 에이전트 배포를 위해 다음 파일들이 생성됩니다: - agents - \ - \.ts 에이전트 배포용 CDK 컨스트럭트 - - Dockerfile CDK 컨스트럭트에서 사용하는 도커 파일 @@ -283,7 +282,7 @@ Bedrock AgentCore Runtime용 Strands 에이전트 빌드를 위해 프로젝트 - [AgentCore 런타임 계약](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-service-contract.html)에 따라 에이전트를 실행하는 `Dockerfile`에서 도커 이미지 빌드 :::tip -도커 이미지는 태그(예: `my-scope-my-project-agent:latest`)를 사용하여 빌드되며, 이는 CDK 또는 Terraform 인프라에서 참조되어 Strands 에이전트 프로젝트와 함께 `Dockerfile`을 배치할 수 있게 합니다. +`Dockerfile`은 Strands 에이전트 프로젝트와 함께 배치됩니다. CDK의 경우 컨스트럭트는 `buildContexts`를 사용하여 이 Dockerfile에서 직접 이미지를 빌드합니다. Terraform의 경우 도커 이미지는 태그(예: `my-scope-my-project-agent:latest`)를 사용하여 사전 빌드되며, 이는 Terraform 인프라에서 참조됩니다. ::: ### 인증 diff --git a/docs/src/content/docs/ko/guides/ts-mcp-server.mdx b/docs/src/content/docs/ko/guides/ts-mcp-server.mdx index 4e309a4fa..3aaf1f6aa 100644 --- a/docs/src/content/docs/ko/guides/ts-mcp-server.mdx +++ b/docs/src/content/docs/ko/guides/ts-mcp-server.mdx @@ -153,7 +153,7 @@ MCP 서버를 테스트하고 사용하는 가장 쉬운 방법은 검사기를 생성기는 [MCP 프로토콜 계약](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-service-contract.html#mcp-protocol-contract)에 따라 포트 `8000`에서 번들된 Streamable HTTP MCP 서버를 실행하는 `-docker` 타겟을 구성합니다. :::tip -도커 이미지는 태그(예: `my-scope-my-project-mcp-server:latest`)를 사용하여 빌드되며, CDK 컨스트럭트의 `Dockerfile`은 이를 상속받아 MCP 서버 프로젝트와 함께 배치될 수 있습니다. +`Dockerfile`은 MCP 서버 프로젝트와 함께 배치됩니다. CDK의 경우 컨스트럭트가 `buildContexts`를 사용하여 이 Dockerfile에서 직접 이미지를 빌드합니다. Terraform의 경우 도커 이미지는 태그(예: `my-scope-my-project-mcp-server:latest`)를 사용하여 사전 빌드되며, Terraform 인프라에서 이를 참조합니다. ::: 여러 MCP 서버가 정의된 경우 모든 서버의 도커 빌드를 실행하는 `docker` 타겟도 생성됩니다. diff --git a/docs/src/content/docs/ko/guides/ts-strands-agent.mdx b/docs/src/content/docs/ko/guides/ts-strands-agent.mdx index 2f44afe53..244c32898 100644 --- a/docs/src/content/docs/ko/guides/ts-strands-agent.mdx +++ b/docs/src/content/docs/ko/guides/ts-strands-agent.mdx @@ -78,7 +78,6 @@ Strands Agent 배포를 위해 다음 파일이 생성됩니다: - agents - \ - \.ts 에이전트 배포를 위한 CDK 구성 - - Dockerfile CDK 구성에서 사용하는 패스스루 도커 파일 @@ -207,7 +206,7 @@ Strands 에이전트 작성에 대한 더 심층적인 가이드는 [Strands 문 생성기는 [AgentCore 런타임 계약](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-service-contract.html)에 따라 포트 `8080`에서 번들된 WebSocket 서버를 실행하는 `-docker` 타겟을 구성합니다. :::tip -도커 이미지는 태그(예: `my-scope-my-project-agent:latest`)를 사용하여 빌드되며, 이는 CDK 또는 Terraform 인프라에서 참조되므로 `Dockerfile`을 Strands Agent 프로젝트와 함께 배치할 수 있습니다. +`Dockerfile`은 Strands Agent 프로젝트와 함께 배치됩니다. CDK의 경우, 구성이 `buildContexts`를 사용하여 이 Dockerfile에서 직접 이미지를 빌드합니다. Terraform의 경우, 도커 이미지는 태그(예: `my-scope-my-project-agent:latest`)를 사용하여 사전 빌드되며, 이는 Terraform 인프라에서 참조됩니다. ::: 여러 에이전트가 정의된 경우 모든 에이전트에 대한 도커 빌드를 실행하는 `docker` 타겟도 생성됩니다. diff --git a/docs/src/content/docs/ko/snippets/mcp/shared-constructs.mdx b/docs/src/content/docs/ko/snippets/mcp/shared-constructs.mdx index 31e19908a..afe926b84 100644 --- a/docs/src/content/docs/ko/snippets/mcp/shared-constructs.mdx +++ b/docs/src/content/docs/ko/snippets/mcp/shared-constructs.mdx @@ -15,7 +15,6 @@ MCP 서버를 배포하기 위해 다음 파일들이 생성됩니다: - mcp-servers - \ - \.ts MCP 서버 배포를 위한 CDK construct - - Dockerfile CDK construct에서 사용되는 Passthrough docker 파일 diff --git a/docs/src/content/docs/pt/get_started/tutorials/dungeon-game/1.mdx b/docs/src/content/docs/pt/get_started/tutorials/dungeon-game/1.mdx index e20c11cf6..77ff27b84 100644 --- a/docs/src/content/docs/pt/get_started/tutorials/dungeon-game/1.mdx +++ b/docs/src/content/docs/pt/get_started/tutorials/dungeon-game/1.mdx @@ -508,10 +508,9 @@ Este é o ponto de entrada do agente, configurado como uma aplicação FastAPI c ```ts // common/constructs/src/app/agents/story-agent.ts -import { Lazy, Names } from 'aws-cdk-lib'; +import { FileSystem, Lazy, Names } from 'aws-cdk-lib'; import { Platform } from 'aws-cdk-lib/aws-ecr-assets'; import { Construct } from 'constructs'; -import { execSync } from 'child_process'; import * as path from 'path'; import * as url from 'url'; import { @@ -520,6 +519,7 @@ import { Runtime, RuntimeProps, } from '@aws-cdk/aws-bedrock-agentcore-alpha'; +import { findWorkspaceRoot } from '../../../core/utils.js'; export type StoryAgentProps = Omit< RuntimeProps, @@ -533,14 +533,23 @@ export class StoryAgent extends Construct { constructor(scope: Construct, id: string, props?: StoryAgentProps) { super(scope, id); - this.dockerImage = AgentRuntimeArtifact.fromAsset( + const workspaceRoot = findWorkspaceRoot( path.dirname(url.fileURLToPath(new URL(import.meta.url))), + ); + + this.dockerImage = AgentRuntimeArtifact.fromAsset( + path.join(workspaceRoot, 'packages/dungeon-adventure/story/src/agent'), { platform: Platform.LINUX_ARM64, - extraHash: execSync( - `docker inspect dungeon-adventure-story-agent:latest --format '{{.Id}}'`, - { encoding: 'utf-8' }, - ).trim(), + buildContexts: { + workspace: workspaceRoot, + }, + extraHash: FileSystem.fingerprint( + path.join( + workspaceRoot, + 'dist/packages/dungeon-adventure/story/bundle/agent/story-agent', + ), + ), }, ); @@ -557,9 +566,7 @@ export class StoryAgent extends Construct { } ``` -Isso configura um `AgentRuntimeArtifact` do CDK que envia sua imagem Docker do agente para o ECR e a hospeda usando o AgentCore Runtime. - -Você pode notar um `Dockerfile` extra, que referencia a imagem Docker do projeto `story`, permitindo que co-localizemos o Dockerfile e o código-fonte do agente. +Isso configura um `AgentRuntimeArtifact` do CDK que envia sua imagem Docker do agente para o ECR e a hospeda usando o AgentCore Runtime. Ele usa `buildContexts` do CDK para referenciar a raiz do workspace, permitindo que o Dockerfile seja co-localizado com o código-fonte do agente. diff --git a/docs/src/content/docs/pt/guides/py-mcp-server.mdx b/docs/src/content/docs/pt/guides/py-mcp-server.mdx index a9863b54a..423b9fd39 100644 --- a/docs/src/content/docs/pt/guides/py-mcp-server.mdx +++ b/docs/src/content/docs/pt/guides/py-mcp-server.mdx @@ -149,7 +149,7 @@ Um alvo `docker` específico para seu servidor MCP também é adicionado, que: - Constrói uma imagem docker a partir do `Dockerfile` que executa seu servidor MCP na porta `8000`, conforme [contrato do protocolo MCP](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-service-contract.html#mcp-protocol-contract) :::tip -A imagem docker é construída usando uma tag (exemplo `my-scope-my-project-mcp-server:latest`), referenciada por sua infraestrutura CDK ou Terraform, permitindo que seu `Dockerfile` fique colocado junto ao projeto do servidor MCP. +Seu `Dockerfile` fica colocado junto ao projeto do servidor MCP. Para CDK, o construct usa `buildContexts` para construir a imagem diretamente a partir deste Dockerfile. Para Terraform, a imagem docker é pré-construída usando uma tag (exemplo `my-scope-my-project-mcp-server:latest`) que é referenciada por sua infraestrutura Terraform. ::: ### Observabilidade diff --git a/docs/src/content/docs/pt/guides/py-strands-agent.mdx b/docs/src/content/docs/pt/guides/py-strands-agent.mdx index 6fe91e0de..5275a5de4 100644 --- a/docs/src/content/docs/pt/guides/py-strands-agent.mdx +++ b/docs/src/content/docs/pt/guides/py-strands-agent.mdx @@ -76,7 +76,6 @@ Para implantar seu Agente Strands, os seguintes arquivos são gerados: - agents - \ - \.ts Construct CDK para implantar seu agente - - Dockerfile Arquivo Docker repassado usado pelo construct CDK @@ -283,7 +282,7 @@ Um alvo `docker` específico para seu Agente Strands também é adicionado, que: - Constrói uma imagem Docker a partir do `Dockerfile` que executa seu agente, conforme o [contrato de runtime do AgentCore](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-service-contract.html) :::tip -A imagem Docker é construída usando uma tag (por exemplo `my-scope-my-project-agent:latest`), que é referenciada por sua infraestrutura CDK ou Terraform, permitindo que seu `Dockerfile` fique co-localizado com seu projeto do Agente Strands. +Seu `Dockerfile` fica co-localizado com seu projeto do Agente Strands. Para CDK, o construct usa `buildContexts` para construir a imagem diretamente a partir deste Dockerfile. Para Terraform, a imagem Docker é pré-construída usando uma tag (por exemplo `my-scope-my-project-agent:latest`) que é referenciada por sua infraestrutura Terraform. ::: ### Autenticação diff --git a/docs/src/content/docs/pt/guides/ts-mcp-server.mdx b/docs/src/content/docs/pt/guides/ts-mcp-server.mdx index a478fc8f6..1a24a7f1d 100644 --- a/docs/src/content/docs/pt/guides/ts-mcp-server.mdx +++ b/docs/src/content/docs/pt/guides/ts-mcp-server.mdx @@ -153,7 +153,7 @@ O alvo de bundle usa `http.ts` como ponto de entrada para o servidor MCP HTTP St O gerador configura um alvo `-docker` que executa o servidor MCP HTTP Streamable empacotado na porta `8000` conforme o [contrato do protocolo MCP](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-service-contract.html#mcp-protocol-contract). :::tip -A imagem docker é construída usando uma tag (por exemplo `my-scope-my-project-mcp-server:latest`), da qual o constructo CDK `Dockerfile` herda, permitindo que seu `Dockerfile` fique colocado junto ao projeto do servidor MCP. +Seu `Dockerfile` fica colocado junto ao projeto do servidor MCP. Para CDK, o constructo usa `buildContexts` para construir a imagem diretamente deste Dockerfile. Para Terraform, a imagem docker é pré-construída usando uma tag (por exemplo `my-scope-my-project-mcp-server:latest`) que é referenciada pela sua infraestrutura Terraform. ::: Um alvo `docker` também é gerado para executar o build docker para todos servidores MCP se você tiver múltiplos definidos. diff --git a/docs/src/content/docs/pt/guides/ts-strands-agent.mdx b/docs/src/content/docs/pt/guides/ts-strands-agent.mdx index 242d865cb..01dd8338c 100644 --- a/docs/src/content/docs/pt/guides/ts-strands-agent.mdx +++ b/docs/src/content/docs/pt/guides/ts-strands-agent.mdx @@ -78,7 +78,6 @@ Para implantar seu Strands Agent, os seguintes arquivos são gerados: - agents - \ - \.ts Construto CDK para implantar seu agente - - Dockerfile Arquivo docker passthrough usado pelo construto CDK @@ -207,7 +206,7 @@ O destino bundle usa `index.ts` como ponto de entrada para o servidor WebSocket O gerador configura um destino `-docker` que executa o servidor WebSocket empacotado na porta `8080` conforme o [contrato de runtime do AgentCore](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-service-contract.html). :::tip -A imagem docker é construída usando uma tag (por exemplo `my-scope-my-project-agent:latest`), que é referenciada pela sua infraestrutura CDK ou Terraform, permitindo que seu `Dockerfile` seja co-localizado com seu projeto Strands Agent. +Seu `Dockerfile` é co-localizado com seu projeto Strands Agent. Para CDK, o construto usa `buildContexts` para construir a imagem diretamente a partir deste Dockerfile. Para Terraform, a imagem docker é pré-construída usando uma tag (por exemplo `my-scope-my-project-agent:latest`) que é referenciada pela sua infraestrutura Terraform. ::: Um destino `docker` também é gerado que executa o docker build para todos os agentes se você tiver múltiplos definidos. diff --git a/docs/src/content/docs/pt/snippets/mcp/shared-constructs.mdx b/docs/src/content/docs/pt/snippets/mcp/shared-constructs.mdx index d6f484d38..2061cd5da 100644 --- a/docs/src/content/docs/pt/snippets/mcp/shared-constructs.mdx +++ b/docs/src/content/docs/pt/snippets/mcp/shared-constructs.mdx @@ -15,7 +15,6 @@ Para implantar seu MCP Server, os seguintes arquivos são gerados: - mcp-servers - \ - \.ts Construto CDK para implantar seu MCP Server - - Dockerfile Arquivo Docker passthrough usado pelo construto CDK diff --git a/docs/src/content/docs/vi/get_started/tutorials/dungeon-game/1.mdx b/docs/src/content/docs/vi/get_started/tutorials/dungeon-game/1.mdx index 18b9925dd..dee3994bf 100644 --- a/docs/src/content/docs/vi/get_started/tutorials/dungeon-game/1.mdx +++ b/docs/src/content/docs/vi/get_started/tutorials/dungeon-game/1.mdx @@ -508,10 +508,9 @@ if __name__ == "__main__": ```ts // common/constructs/src/app/agents/story-agent.ts -import { Lazy, Names } from 'aws-cdk-lib'; +import { FileSystem, Lazy, Names } from 'aws-cdk-lib'; import { Platform } from 'aws-cdk-lib/aws-ecr-assets'; import { Construct } from 'constructs'; -import { execSync } from 'child_process'; import * as path from 'path'; import * as url from 'url'; import { @@ -520,6 +519,7 @@ import { Runtime, RuntimeProps, } from '@aws-cdk/aws-bedrock-agentcore-alpha'; +import { findWorkspaceRoot } from '../../../core/utils.js'; export type StoryAgentProps = Omit< RuntimeProps, @@ -533,14 +533,23 @@ export class StoryAgent extends Construct { constructor(scope: Construct, id: string, props?: StoryAgentProps) { super(scope, id); - this.dockerImage = AgentRuntimeArtifact.fromAsset( + const workspaceRoot = findWorkspaceRoot( path.dirname(url.fileURLToPath(new URL(import.meta.url))), + ); + + this.dockerImage = AgentRuntimeArtifact.fromAsset( + path.join(workspaceRoot, 'packages/dungeon-adventure/story/src/agent'), { platform: Platform.LINUX_ARM64, - extraHash: execSync( - `docker inspect dungeon-adventure-story-agent:latest --format '{{.Id}}'`, - { encoding: 'utf-8' }, - ).trim(), + buildContexts: { + workspace: workspaceRoot, + }, + extraHash: FileSystem.fingerprint( + path.join( + workspaceRoot, + 'dist/packages/dungeon-adventure/story/bundle/agent/story-agent', + ), + ), }, ); @@ -557,9 +566,7 @@ export class StoryAgent extends Construct { } ``` -Điều này cấu hình một CDK `AgentRuntimeArtifact` tải image Docker agent của bạn lên ECR và lưu trữ nó bằng AgentCore Runtime. - -Bạn có thể nhận thấy một `Dockerfile` bổ sung, tham chiếu đến Docker image từ dự án `story`, cho phép chúng ta đặt cùng vị trí Dockerfile và mã nguồn agent. +Điều này cấu hình một CDK `AgentRuntimeArtifact` tải image Docker agent của bạn lên ECR và lưu trữ nó bằng AgentCore Runtime. Nó sử dụng `buildContexts` của CDK để tham chiếu gốc workspace, cho phép Dockerfile được đặt cùng vị trí với mã nguồn agent. diff --git a/docs/src/content/docs/vi/guides/py-mcp-server.mdx b/docs/src/content/docs/vi/guides/py-mcp-server.mdx index 98b79dd65..96e2c2a47 100644 --- a/docs/src/content/docs/vi/guides/py-mcp-server.mdx +++ b/docs/src/content/docs/vi/guides/py-mcp-server.mdx @@ -149,7 +149,7 @@ Một target `docker` cụ thể cho máy chủ MCP của bạn cũng được t - Xây dựng một docker image từ `Dockerfile` chạy máy chủ MCP của bạn trên cổng `8000`, theo [hợp đồng giao thức MCP](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-service-contract.html#mcp-protocol-contract) :::tip -Docker image được xây dựng bằng cách sử dụng một tag (ví dụ `my-scope-my-project-mcp-server:latest`), được tham chiếu bởi hạ tầng CDK hoặc Terraform của bạn, cho phép `Dockerfile` của bạn được đặt cùng vị trí với dự án máy chủ MCP của bạn. +`Dockerfile` của bạn được đặt cùng vị trí với dự án máy chủ MCP của bạn. Đối với CDK, construct sử dụng `buildContexts` để xây dựng image trực tiếp từ Dockerfile này. Đối với Terraform, docker image được xây dựng trước bằng cách sử dụng một tag (ví dụ `my-scope-my-project-mcp-server:latest`) được tham chiếu bởi hạ tầng Terraform của bạn. ::: ### Khả năng quan sát diff --git a/docs/src/content/docs/vi/guides/py-strands-agent.mdx b/docs/src/content/docs/vi/guides/py-strands-agent.mdx index 968ddad34..e1dc5c4b2 100644 --- a/docs/src/content/docs/vi/guides/py-strands-agent.mdx +++ b/docs/src/content/docs/vi/guides/py-strands-agent.mdx @@ -76,7 +76,6 @@ Nếu bạn chọn `None` cho `computeType`, generator sẽ không tạo bất k - agents - \ - \.ts CDK construct để triển khai agent của bạn - - Dockerfile File docker passthrough được sử dụng bởi CDK construct @@ -283,7 +282,7 @@ Một target `docker` cụ thể cho Strands Agent của bạn cũng được th - Build một docker image từ `Dockerfile` chạy agent của bạn, theo [hợp đồng runtime AgentCore](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-service-contract.html) :::tip -Docker image được build bằng một tag (ví dụ `my-scope-my-project-agent:latest`), được tham chiếu bởi hạ tầng CDK hoặc Terraform của bạn, cho phép `Dockerfile` của bạn được đặt cùng với Strands Agent project của bạn. +`Dockerfile` của bạn được đặt cùng với Strands Agent project của bạn. Đối với CDK, construct sử dụng `buildContexts` để build image trực tiếp từ Dockerfile này. Đối với Terraform, docker image được pre-built bằng một tag (ví dụ `my-scope-my-project-agent:latest`) được tham chiếu bởi hạ tầng Terraform của bạn. ::: ### Xác thực @@ -345,7 +344,7 @@ module "my_project_agent" { -#### Cognito JWT Authentication +#### Xác thực JWT / Cognito Dưới đây minh họa cách cấu hình xác thực Cognito cho agent của bạn. diff --git a/docs/src/content/docs/vi/guides/ts-mcp-server.mdx b/docs/src/content/docs/vi/guides/ts-mcp-server.mdx index 9928d6f37..fb94d1f11 100644 --- a/docs/src/content/docs/vi/guides/ts-mcp-server.mdx +++ b/docs/src/content/docs/vi/guides/ts-mcp-server.mdx @@ -153,7 +153,7 @@ Bundle target sử dụng `http.ts` làm điểm vào cho máy chủ MCP Streama Generator cấu hình một target `-docker` chạy máy chủ MCP Streamable HTTP đã được đóng gói trên cổng `8000` theo [MCP protocol contract](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-service-contract.html#mcp-protocol-contract). :::tip -Docker image được xây dựng bằng cách sử dụng một tag (ví dụ `my-scope-my-project-mcp-server:latest`), mà `Dockerfile` của CDK construct kế thừa từ đó, cho phép `Dockerfile` của bạn được đặt cùng vị trí với dự án máy chủ MCP của bạn. +`Dockerfile` của bạn được đặt cùng vị trí với dự án máy chủ MCP của bạn. Đối với CDK, construct sử dụng `buildContexts` để xây dựng image trực tiếp từ Dockerfile này. Đối với Terraform, docker image được xây dựng trước bằng cách sử dụng một tag (ví dụ `my-scope-my-project-mcp-server:latest`) được tham chiếu bởi cơ sở hạ tầng Terraform của bạn. ::: Một target `docker` cũng được tạo ra để chạy docker build cho tất cả các máy chủ MCP nếu bạn có nhiều máy chủ được định nghĩa. diff --git a/docs/src/content/docs/vi/guides/ts-strands-agent.mdx b/docs/src/content/docs/vi/guides/ts-strands-agent.mdx index f9380a14c..047a35846 100644 --- a/docs/src/content/docs/vi/guides/ts-strands-agent.mdx +++ b/docs/src/content/docs/vi/guides/ts-strands-agent.mdx @@ -78,7 +78,6 @@ Nếu bạn chọn `None` cho `computeType`, generator sẽ không cung cấp b - agents - \ - \.ts CDK construct để triển khai agent của bạn - - Dockerfile File docker passthrough được sử dụng bởi CDK construct @@ -207,7 +206,7 @@ Bundle target sử dụng `index.ts` làm entrypoint cho WebSocket server để Generator cấu hình một target `-docker` chạy WebSocket server đã được bundle trên cổng `8080` theo [hợp đồng runtime của AgentCore](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-service-contract.html). :::tip -Docker image được build sử dụng một tag (ví dụ `my-scope-my-project-agent:latest`), được tham chiếu bởi hạ tầng CDK hoặc Terraform của bạn, cho phép `Dockerfile` của bạn được đặt cùng với dự án Strands Agent của bạn. +`Dockerfile` của bạn được đặt cùng với dự án Strands Agent của bạn. Đối với CDK, construct sử dụng `buildContexts` để build image trực tiếp từ Dockerfile này. Đối với Terraform, docker image được pre-built sử dụng một tag (ví dụ `my-scope-my-project-agent:latest`) được tham chiếu bởi hạ tầng Terraform của bạn. ::: Một target `docker` cũng được tạo ra để chạy docker build cho tất cả các agent nếu bạn có nhiều agent được định nghĩa. diff --git a/docs/src/content/docs/vi/snippets/mcp/shared-constructs.mdx b/docs/src/content/docs/vi/snippets/mcp/shared-constructs.mdx index 7110ff437..1904cc53c 100644 --- a/docs/src/content/docs/vi/snippets/mcp/shared-constructs.mdx +++ b/docs/src/content/docs/vi/snippets/mcp/shared-constructs.mdx @@ -15,7 +15,6 @@ import Infrastructure from '@components/infrastructure.astro'; - mcp-servers - \ - \.ts CDK construct để triển khai MCP Server của bạn - - Dockerfile Tệp docker passthrough được sử dụng bởi CDK construct diff --git a/docs/src/content/docs/zh/get_started/tutorials/dungeon-game/1.mdx b/docs/src/content/docs/zh/get_started/tutorials/dungeon-game/1.mdx index 34183c24d..a1eec82d9 100644 --- a/docs/src/content/docs/zh/get_started/tutorials/dungeon-game/1.mdx +++ b/docs/src/content/docs/zh/get_started/tutorials/dungeon-game/1.mdx @@ -505,10 +505,9 @@ if __name__ == "__main__": ```ts // common/constructs/src/app/agents/story-agent.ts -import { Lazy, Names } from 'aws-cdk-lib'; +import { FileSystem, Lazy, Names } from 'aws-cdk-lib'; import { Platform } from 'aws-cdk-lib/aws-ecr-assets'; import { Construct } from 'constructs'; -import { execSync } from 'child_process'; import * as path from 'path'; import * as url from 'url'; import { @@ -517,6 +516,7 @@ import { Runtime, RuntimeProps, } from '@aws-cdk/aws-bedrock-agentcore-alpha'; +import { findWorkspaceRoot } from '../../../core/utils.js'; export type StoryAgentProps = Omit< RuntimeProps, @@ -530,14 +530,23 @@ export class StoryAgent extends Construct { constructor(scope: Construct, id: string, props?: StoryAgentProps) { super(scope, id); - this.dockerImage = AgentRuntimeArtifact.fromAsset( + const workspaceRoot = findWorkspaceRoot( path.dirname(url.fileURLToPath(new URL(import.meta.url))), + ); + + this.dockerImage = AgentRuntimeArtifact.fromAsset( + path.join(workspaceRoot, 'packages/dungeon-adventure/story/src/agent'), { platform: Platform.LINUX_ARM64, - extraHash: execSync( - `docker inspect dungeon-adventure-story-agent:latest --format '{{.Id}}'`, - { encoding: 'utf-8' }, - ).trim(), + buildContexts: { + workspace: workspaceRoot, + }, + extraHash: FileSystem.fingerprint( + path.join( + workspaceRoot, + 'dist/packages/dungeon-adventure/story/bundle/agent/story-agent', + ), + ), }, ); @@ -554,9 +563,7 @@ export class StoryAgent extends Construct { } ``` -该配置使用 CDK 的 `AgentRuntimeArtifact` 将代理 Docker 镜像上传到 ECR,并通过 AgentCore Runtime 托管。 - -您可能注意到额外的 `Dockerfile`,它引用了 `story` 项目的 Docker 镜像,允许我们将 Dockerfile 与代理源代码放在一起。 +该配置使用 CDK 的 `AgentRuntimeArtifact` 将代理 Docker 镜像上传到 ECR,并通过 AgentCore Runtime 托管。它使用 CDK 的 `buildContexts` 引用工作区根目录,允许 Dockerfile 与代理源代码放在一起。 diff --git a/docs/src/content/docs/zh/guides/py-mcp-server.mdx b/docs/src/content/docs/zh/guides/py-mcp-server.mdx index 36378117a..c0c0f9a2b 100644 --- a/docs/src/content/docs/zh/guides/py-mcp-server.mdx +++ b/docs/src/content/docs/zh/guides/py-mcp-server.mdx @@ -149,7 +149,7 @@ def dynamic_resource(item_id: str) -> str: - 从`Dockerfile`构建docker镜像,根据[MCP协议约定](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-service-contract.html#mcp-protocol-contract)在8000端口运行MCP服务器 :::tip -docker镜像使用特定标签(例如`my-scope-my-project-mcp-server:latest`)构建,该标签由CDK或Terraform基础设施引用,使得`Dockerfile`可以与MCP服务器项目共存。 +您的`Dockerfile`与MCP服务器项目共存。对于CDK,构造使用`buildContexts`直接从此Dockerfile构建镜像。对于Terraform,docker镜像使用特定标签(例如`my-scope-my-project-mcp-server:latest`)预先构建,该标签由Terraform基础设施引用。 ::: ### 可观测性 diff --git a/docs/src/content/docs/zh/guides/py-strands-agent.mdx b/docs/src/content/docs/zh/guides/py-strands-agent.mdx index fd28d82b0..8aef990cc 100644 --- a/docs/src/content/docs/zh/guides/py-strands-agent.mdx +++ b/docs/src/content/docs/zh/guides/py-strands-agent.mdx @@ -76,7 +76,6 @@ import Drawer from '@components/drawer.astro'; - agents - \ - \.ts 部署智能体的CDK构造 - - Dockerfile CDK构造使用的透传Docker文件 @@ -281,7 +280,7 @@ SDK功能详情请参阅[文档](https://aws.github.io/bedrock-agentcore-starter - 根据[AgentCore运行时协议](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-service-contract.html)构建Docker镜像 :::tip -Docker镜像使用特定标签(如`my-scope-my-project-agent:latest`),与CDK/Terraform基础设施关联,确保Dockerfile与项目位置一致。 +您的`Dockerfile`与Strands智能体项目位于同一位置。对于CDK,构造使用`buildContexts`直接从此Dockerfile构建镜像。对于Terraform,Docker镜像使用标签(如`my-scope-my-project-agent:latest`)预先构建,并由Terraform基础设施引用。 ::: ### 认证配置 @@ -462,8 +461,7 @@ curl -N -X POST http://localhost:8081/invocations \ ```bash acurl bedrock-agentcore -N -X POST \ -'https://bedrock --agentcore..amazonaws.com/runtimes//invocations' \ +'https://bedrock-agentcore..amazonaws.com/runtimes//invocations' \ -d '{"prompt": "what is 3 + 5?", "session_id": "abcdefghijklmnopqrstuvwxyz0123456789"}' \ -H 'Content-Type: application/json' ``` @@ -477,8 +475,7 @@ acurl bedrock-agentcore -N -X POST \ 对于Cognito认证,在`Authorization`标头中传递Cognito访问令牌: ```bash -curl -N -X POST 'https://bedrock --agentcore..amazonaws.com/runtimes//invocations' \ +curl -N -X POST 'https://bedrock-agentcore..amazonaws.com/runtimes//invocations' \ -d '{"prompt": "what is 3 + 5?", "session_id": "abcdefghijklmnopqrstuvwxyz0123456789"}' \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " diff --git a/docs/src/content/docs/zh/guides/ts-mcp-server.mdx b/docs/src/content/docs/zh/guides/ts-mcp-server.mdx index 9132f7de2..69f629762 100644 --- a/docs/src/content/docs/zh/guides/ts-mcp-server.mdx +++ b/docs/src/content/docs/zh/guides/ts-mcp-server.mdx @@ -153,7 +153,7 @@ server.registerResource('dynamic-resource', 'dynamic://resource', {}, async (uri 生成器配置了 `-docker` 目标,该目标根据 [MCP 协议约定](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-service-contract.html#mcp-protocol-contract) 在端口 `8000` 上运行打包后的流式 HTTP MCP 服务器。 :::tip -Docker 镜像使用标签(如 `my-scope-my-project-mcp-server:latest`)构建,CDK 构造的 `Dockerfile` 继承此标签,允许将您的 `Dockerfile` 与 MCP 服务器项目共存。 +您的 `Dockerfile` 与 MCP 服务器项目共存。对于 CDK,构造使用 `buildContexts` 直接从此 Dockerfile 构建镜像。对于 Terraform,Docker 镜像使用标签(如 `my-scope-my-project-mcp-server:latest`)预先构建,并由您的 Terraform 基础设施引用。 ::: 若定义了多个 MCP 服务器,还会生成 `docker` 目标来执行所有 MCP 服务器的 Docker 构建。 diff --git a/docs/src/content/docs/zh/guides/ts-strands-agent.mdx b/docs/src/content/docs/zh/guides/ts-strands-agent.mdx index 74ffb310c..047a9c307 100644 --- a/docs/src/content/docs/zh/guides/ts-strands-agent.mdx +++ b/docs/src/content/docs/zh/guides/ts-strands-agent.mdx @@ -78,7 +78,6 @@ import PackageManagerExecCommand from '@components/package-manager-exec-command. - agents - \ - \.ts 用于部署代理的 CDK 构造 - - Dockerfile CDK 构造使用的传递 docker 文件 @@ -207,7 +206,7 @@ bundle 目标使用 `index.ts` 作为在 Bedrock AgentCore Runtime 上托管的 生成器配置了一个 `-docker` 目标,根据 [AgentCore 运行时契约](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-service-contract.html) 在端口 `8080` 上运行打包的 WebSocket 服务器。 :::tip -docker 镜像使用标签构建(例如 `my-scope-my-project-agent:latest`),该标签由您的 CDK 或 Terraform 基础设施引用,允许您的 `Dockerfile` 与 Strands Agent 项目共存。 +您的 `Dockerfile` 与 Strands Agent 项目共存。对于 CDK,构造使用 `buildContexts` 直接从此 Dockerfile 构建镜像。对于 Terraform,docker 镜像使用标签预先构建(例如 `my-scope-my-project-agent:latest`),该标签由您的 Terraform 基础设施引用。 ::: 如果您定义了多个代理,还会生成一个 `docker` 目标,用于为所有代理运行 docker 构建。 diff --git a/docs/src/content/docs/zh/snippets/mcp/shared-constructs.mdx b/docs/src/content/docs/zh/snippets/mcp/shared-constructs.mdx index 05fa474e3..c5df82057 100644 --- a/docs/src/content/docs/zh/snippets/mcp/shared-constructs.mdx +++ b/docs/src/content/docs/zh/snippets/mcp/shared-constructs.mdx @@ -15,7 +15,6 @@ import Infrastructure from '@components/infrastructure.astro'; - mcp-servers - \ - \.ts 用于部署 MCP 服务器的 CDK 构造 - - Dockerfile CDK 构造使用的直通式 docker 文件 diff --git a/packages/nx-plugin/LICENSE-THIRD-PARTY b/packages/nx-plugin/LICENSE-THIRD-PARTY index 6a16a5a47..e7fe39001 100644 --- a/packages/nx-plugin/LICENSE-THIRD-PARTY +++ b/packages/nx-plugin/LICENSE-THIRD-PARTY @@ -124,7 +124,7 @@ THE SOFTWARE. --- -The following software may be included in this product: @asamuzakjp/css-color (5.0.1) +The following software may be included in this product: @asamuzakjp/css-color (5.1.1) This software contains the following license and notice below: MIT License @@ -234,6 +234,34 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- +The following software may be included in this product: @babel/compat-data (7.28.4) +This software contains the following license and notice below: + +MIT License + +Copyright (c) 2014-present Sebastian McKenzie and other contributors + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +--- + The following software may be included in this product: @babel/compat-data (7.29.0) This software contains the following license and notice below: @@ -402,6 +430,34 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- +The following software may be included in this product: @babel/helper-compilation-targets (7.27.2) +This software contains the following license and notice below: + +MIT License + +Copyright (c) 2014-present Sebastian McKenzie and other contributors + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +--- + The following software may be included in this product: @babel/helper-compilation-targets (7.28.6) This software contains the following license and notice below: @@ -626,6 +682,34 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- +The following software may be included in this product: @babel/helper-module-transforms (7.28.3) +This software contains the following license and notice below: + +MIT License + +Copyright (c) 2014-present Sebastian McKenzie and other contributors + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +--- + The following software may be included in this product: @babel/helper-module-transforms (7.28.6) This software contains the following license and notice below: @@ -906,6 +990,35 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- +The following software may be included in this product: @babel/helpers (7.28.4) +This software contains the following license and notice below: + +MIT License + +Copyright (c) 2014-present Sebastian McKenzie and other contributors +Copyright (c) 2014-present, Facebook, Inc. (ONLY ./src/helpers/regenerator* files) + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +--- + The following software may be included in this product: @babel/helpers (7.29.2) This software contains the following license and notice below: @@ -3617,6 +3730,54 @@ SOFTWARE. --- +The following software may be included in this product: @getgrit/gritql (0.0.3) +This software contains the following license and notice below: + +MIT License + +Copyright (c) The maintainers of @getgrit/gritql + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and +associated documentation files (the "Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the +following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial +portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT +LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO +EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +USE OR OTHER DEALINGS IN THE SOFTWARE. + +--- + +The following software may be included in this product: @getgrit/gritql-linux-arm64-gnu (0.0.3) +This software contains the following license and notice below: + +MIT License + +Copyright (c) The maintainers of @getgrit/gritql-linux-arm64-gnu + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and +associated documentation files (the "Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the +following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial +portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT +LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO +EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +USE OR OTHER DEALINGS IN THE SOFTWARE. + +--- + The following software may be included in this product: @hey-api/json-schema-ref-parser (1.0.3) This software contains the following license and notice below: @@ -4012,7 +4173,7 @@ SOFTWARE. --- -The following software may be included in this product: @module-federation/bridge-react-webpack-plugin (2.2.3) +The following software may be included in this product: @module-federation/bridge-react-webpack-plugin (2.3.0) This software contains the following license and notice below: MIT License @@ -4066,7 +4227,7 @@ SOFTWARE. --- -The following software may be included in this product: @module-federation/cli (2.2.3) +The following software may be included in this product: @module-federation/cli (2.3.0) This software contains the following license and notice below: MIT License @@ -4120,7 +4281,7 @@ SOFTWARE. --- -The following software may be included in this product: @module-federation/data-prefetch (2.2.3) +The following software may be included in this product: @module-federation/data-prefetch (2.3.0) This software contains the following license and notice below: MIT License @@ -4174,7 +4335,7 @@ SOFTWARE. --- -The following software may be included in this product: @module-federation/dts-plugin (2.2.3) +The following software may be included in this product: @module-federation/dts-plugin (2.3.0) This software contains the following license and notice below: MIT License @@ -4228,7 +4389,7 @@ SOFTWARE. --- -The following software may be included in this product: @module-federation/enhanced (2.2.3) +The following software may be included in this product: @module-federation/enhanced (2.3.0) This software contains the following license and notice below: MIT License @@ -4282,7 +4443,7 @@ SOFTWARE. --- -The following software may be included in this product: @module-federation/error-codes (2.2.3) +The following software may be included in this product: @module-federation/error-codes (2.3.0) This software contains the following license and notice below: MIT License @@ -4336,7 +4497,7 @@ SOFTWARE. --- -The following software may be included in this product: @module-federation/inject-external-runtime-core-plugin (2.2.3) +The following software may be included in this product: @module-federation/inject-external-runtime-core-plugin (2.3.0) This software contains the following license and notice below: MIT License @@ -4390,7 +4551,7 @@ SOFTWARE. --- -The following software may be included in this product: @module-federation/managers (2.2.3) +The following software may be included in this product: @module-federation/managers (2.3.0) This software contains the following license and notice below: MIT License @@ -4444,7 +4605,7 @@ SOFTWARE. --- -The following software may be included in this product: @module-federation/manifest (2.2.3) +The following software may be included in this product: @module-federation/manifest (2.3.0) This software contains the following license and notice below: MIT License @@ -4525,7 +4686,7 @@ SOFTWARE. --- -The following software may be included in this product: @module-federation/rspack (2.2.3) +The following software may be included in this product: @module-federation/rspack (2.3.0) This software contains the following license and notice below: MIT License @@ -4579,7 +4740,7 @@ SOFTWARE. --- -The following software may be included in this product: @module-federation/runtime (2.2.3) +The following software may be included in this product: @module-federation/runtime (2.3.0) This software contains the following license and notice below: MIT License @@ -4633,7 +4794,7 @@ SOFTWARE. --- -The following software may be included in this product: @module-federation/runtime-core (2.2.3) +The following software may be included in this product: @module-federation/runtime-core (2.3.0) This software contains the following license and notice below: MIT License @@ -4687,7 +4848,7 @@ SOFTWARE. --- -The following software may be included in this product: @module-federation/runtime-tools (2.2.3) +The following software may be included in this product: @module-federation/runtime-tools (2.3.0) This software contains the following license and notice below: MIT License @@ -4741,7 +4902,7 @@ SOFTWARE. --- -The following software may be included in this product: @module-federation/sdk (2.2.3) +The following software may be included in this product: @module-federation/sdk (2.3.0) This software contains the following license and notice below: MIT License @@ -4795,7 +4956,7 @@ SOFTWARE. --- -The following software may be included in this product: @module-federation/third-party-dts-extractor (2.2.3) +The following software may be included in this product: @module-federation/third-party-dts-extractor (2.3.0) This software contains the following license and notice below: MIT License @@ -4849,7 +5010,7 @@ SOFTWARE. --- -The following software may be included in this product: @module-federation/webpack-bundler-runtime (2.2.3) +The following software may be included in this product: @module-federation/webpack-bundler-runtime (2.3.0) This software contains the following license and notice below: MIT License @@ -7982,7 +8143,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- -The following software may be included in this product: acorn (8.16.0) +The following software may be included in this product: acorn (8.15.0) This software contains the following license and notice below: MIT License @@ -8761,7 +8922,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI --- -The following software may be included in this product: axios (1.13.6) +The following software may be included in this product: axios (1.14.0) This software contains the following license and notice below: # Copyright (c) 2014-present Matt Zabriskie & Collaborators @@ -15727,6 +15888,33 @@ THE SOFTWARE. --- +The following software may be included in this product: js-yaml (4.1.0) +This software contains the following license and notice below: + +(The MIT License) + +Copyright (C) 2011-2015 by Vitaly Puzrin + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +--- + The following software may be included in this product: js-yaml (4.1.1) This software contains the following license and notice below: @@ -20450,6 +20638,32 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- +The following software may be included in this product: proxy-from-env (2.1.0) +This software contains the following license and notice below: + +The MIT License + +Copyright (C) 2016-2018 Rob Wu + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +--- + The following software may be included in this product: prr (1.0.1) This software contains the following license and notice below: @@ -26084,7 +26298,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --- -The following software may be included in this product: ufo (1.6.3) +The following software may be included in this product: ufo (1.6.1) This software contains the following license and notice below: MIT License @@ -30177,7 +30391,7 @@ SOFTWARE. --- -The following software may be included in this product: @csstools/css-syntax-patches-for-csstree (1.1.1) +The following software may be included in this product: @csstools/css-syntax-patches-for-csstree (1.1.2) This software contains the following license and notice below: MIT No Attribution (MIT-0) @@ -37594,36 +37808,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND --- -The following software may be included in this product: esquery (1.6.0) -This software contains the following license and notice below: - -Copyright (c) 2013, Joel Feenstra -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the ESQuery nor the names of its contributors may - be used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL JOEL FEENSTRA BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ---- - The following software may be included in this product: esquery (1.7.0) This software contains the following license and notice below: diff --git a/packages/nx-plugin/src/infra/app/__snapshots__/generator.spec.ts.snap b/packages/nx-plugin/src/infra/app/__snapshots__/generator.spec.ts.snap index dbd60cd42..280813ca7 100644 --- a/packages/nx-plugin/src/infra/app/__snapshots__/generator.spec.ts.snap +++ b/packages/nx-plugin/src/infra/app/__snapshots__/generator.spec.ts.snap @@ -3,7 +3,7 @@ exports[`infra generator > should add required dependencies to package.json > dependencies 1`] = ` { "aws-cdk": "2.1113.0", - "aws-cdk-lib": "2.244.0", + "aws-cdk-lib": "2.245.0", "constructs": "10.6.0", "esbuild": "0.27.4", "source-map-support": "0.5.21", @@ -40,7 +40,7 @@ exports[`infra generator > should add required dependencies to package.json > pa { "dependencies": { "aws-cdk": "2.1113.0", - "aws-cdk-lib": "2.244.0", + "aws-cdk-lib": "2.245.0", "constructs": "10.6.0", "esbuild": "0.27.4", "source-map-support": "0.5.21", diff --git a/packages/nx-plugin/src/py/mcp-server/__snapshots__/generator.spec.ts.snap b/packages/nx-plugin/src/py/mcp-server/__snapshots__/generator.spec.ts.snap index f2ada7606..6508df209 100644 --- a/packages/nx-plugin/src/py/mcp-server/__snapshots__/generator.spec.ts.snap +++ b/packages/nx-plugin/src/py/mcp-server/__snapshots__/generator.spec.ts.snap @@ -9,14 +9,14 @@ exports[`py#mcp-server generator > should match snapshot for BedrockAgentCoreRun "export * from './app.js'; export * from './checkov.js'; export * from './runtime-config.js'; +export * from './utils.js'; " `; exports[`py#mcp-server generator > should match snapshot for BedrockAgentCoreRuntime generated constructs files > mcp-server-construct.ts 1`] = ` -"import { Lazy, Names } from 'aws-cdk-lib'; +"import { FileSystem, Lazy, Names } from 'aws-cdk-lib'; import { Platform } from 'aws-cdk-lib/aws-ecr-assets'; import { Construct } from 'constructs'; -import { execSync } from 'child_process'; import * as path from 'path'; import * as url from 'url'; import { @@ -26,6 +26,7 @@ import { RuntimeProps, } from '@aws-cdk/aws-bedrock-agentcore-alpha'; import { RuntimeConfig } from '../../../core/runtime-config.js'; +import { findWorkspaceRoot } from '../../../core/utils.js'; export type SnapshotBedrockServerProps = Omit< RuntimeProps, @@ -45,14 +46,23 @@ export class SnapshotBedrockServer extends Construct { const rc = RuntimeConfig.ensure(this); - this.dockerImage = AgentRuntimeArtifact.fromAsset( + const workspaceRoot = findWorkspaceRoot( path.dirname(url.fileURLToPath(new URL(import.meta.url))), + ); + + this.dockerImage = AgentRuntimeArtifact.fromAsset( + path.join( + workspaceRoot, + 'apps/test-project/proj_test_project/snapshot_bedrock_server', + ), { platform: Platform.LINUX_ARM64, - extraHash: execSync( - \`docker inspect proj-snapshot-bedrock-server:latest --format '{{.Id}}'\`, - { encoding: 'utf-8' }, - ).trim(), + buildContexts: { + workspace: workspaceRoot, + }, + extraHash: FileSystem.fingerprint( + path.join(workspaceRoot, 'dist/apps/test-project/bundle-arm'), + ), }, ); diff --git a/packages/nx-plugin/src/py/mcp-server/generator.spec.ts b/packages/nx-plugin/src/py/mcp-server/generator.spec.ts index 1d870c2eb..e4dd07329 100644 --- a/packages/nx-plugin/src/py/mcp-server/generator.spec.ts +++ b/packages/nx-plugin/src/py/mcp-server/generator.spec.ts @@ -377,8 +377,8 @@ dev-dependencies = [] 'bundle-arm', ); - // Check that build target depends on docker - expect(projectConfig.targets.build.dependsOn).toContain('docker'); + // For CDK, build target should not depend on docker (CDK builds via buildContexts) + expect(projectConfig.targets.build.dependsOn).not.toContain('docker'); }); it('should generate MCP server with BedrockAgentCoreRuntime and custom name', async () => { @@ -521,21 +521,12 @@ dev-dependencies = [] iacProvider: 'CDK', }); - expect( - tree.read( - 'packages/common/constructs/src/app/mcp-servers/my-server/Dockerfile', - 'utf-8', - ), - ).toContain('my-scope-my-server:latest'); - - // Check that the docker image tag is correctly generated in the MCP server construct + // Check that the CDK construct uses buildContexts const mcpServerConstruct = tree.read( 'packages/common/constructs/src/app/mcp-servers/my-server/my-server.ts', 'utf-8', ); - expect(mcpServerConstruct).toContain( - 'docker inspect my-scope-my-server:latest', - ); + expect(mcpServerConstruct).toContain('buildContexts'); }); it('should match snapshot for BedrockAgentCoreRuntime generated constructs files', async () => { @@ -676,8 +667,8 @@ dev-dependencies = [] expect(projectConfig.targets.docker).toBeDefined(); expect(projectConfig.targets.docker.dependsOn).toContain(dockerTargetName); - // Check that build target depends on docker - expect(projectConfig.targets.build.dependsOn).toContain('docker'); + // For CDK, build target should not depend on docker (CDK builds via buildContexts) + expect(projectConfig.targets.build.dependsOn).not.toContain('docker'); }); it('should generate MCP server with Terraform provider and default name', async () => { diff --git a/packages/nx-plugin/src/py/mcp-server/generator.ts b/packages/nx-plugin/src/py/mcp-server/generator.ts index 233366150..d3d14bc16 100644 --- a/packages/nx-plugin/src/py/mcp-server/generator.ts +++ b/packages/nx-plugin/src/py/mcp-server/generator.ts @@ -121,6 +121,10 @@ export const pyMcpServerGenerator = async ( { overwriteStrategy: OverwriteStrategy.KeepExisting }, ); + // Add shared constructs + const iacProvider = await resolveIacProvider(tree, options.iacProvider); + await sharedConstructsGenerator(tree, { iacProvider }); + const dockerTargetName = `${mcpTargetPrefix}-docker`; // Add a docker target specific to this MCP server @@ -146,19 +150,19 @@ export const pyMcpServerGenerator = async ( ], }; - project.targets.build = { - ...project.targets.build, - dependsOn: [ - ...(project.targets.build?.dependsOn ?? []).filter( - (t) => t !== 'docker', - ), - 'docker', - ], - }; - - // Add shared constructs - const iacProvider = await resolveIacProvider(tree, options.iacProvider); - await sharedConstructsGenerator(tree, { iacProvider }); + // For Terraform, the docker image must be pre-built before deploy. + // For CDK, the image is built via DockerImageAsset with buildContexts. + if (iacProvider !== 'CDK') { + project.targets.build = { + ...project.targets.build, + dependsOn: [ + ...(project.targets.build?.dependsOn ?? []).filter( + (t) => t !== 'docker', + ), + 'docker', + ], + }; + } // Add the construct to deploy the mcp server await addMcpServerInfra(tree, { @@ -166,6 +170,8 @@ export const pyMcpServerGenerator = async ( mcpServerNameClassName, projectName: project.name, dockerImageTag, + dockerfileDir: targetSourceDir, + bundleOutputDir, iacProvider, }); } diff --git a/packages/nx-plugin/src/py/strands-agent/__snapshots__/generator.spec.ts.snap b/packages/nx-plugin/src/py/strands-agent/__snapshots__/generator.spec.ts.snap index 377617813..a51a4cd01 100644 --- a/packages/nx-plugin/src/py/strands-agent/__snapshots__/generator.spec.ts.snap +++ b/packages/nx-plugin/src/py/strands-agent/__snapshots__/generator.spec.ts.snap @@ -19,10 +19,9 @@ CMD ["python", "bin/opentelemetry-instrument", "python", "-m", "proj_test_projec `; exports[`py#strands-agent generator > should match snapshot for BedrockAgentCoreRuntime generated constructs files > agent-construct.ts 1`] = ` -"import { Lazy, Names } from 'aws-cdk-lib'; +"import { FileSystem, Lazy, Names } from 'aws-cdk-lib'; import { Platform } from 'aws-cdk-lib/aws-ecr-assets'; import { Construct } from 'constructs'; -import { execSync } from 'child_process'; import * as path from 'path'; import * as url from 'url'; import { @@ -32,6 +31,7 @@ import { RuntimeProps, } from '@aws-cdk/aws-bedrock-agentcore-alpha'; import { RuntimeConfig } from '../../../core/runtime-config.js'; +import { findWorkspaceRoot } from '../../../core/utils.js'; export type SnapshotBedrockAgentProps = Omit< RuntimeProps, @@ -47,14 +47,23 @@ export class SnapshotBedrockAgent extends Construct { const rc = RuntimeConfig.ensure(this); - this.dockerImage = AgentRuntimeArtifact.fromAsset( + const workspaceRoot = findWorkspaceRoot( path.dirname(url.fileURLToPath(new URL(import.meta.url))), + ); + + this.dockerImage = AgentRuntimeArtifact.fromAsset( + path.join( + workspaceRoot, + 'apps/test-project/proj_test_project/snapshot_bedrock_agent', + ), { platform: Platform.LINUX_ARM64, - extraHash: execSync( - \`docker inspect proj-snapshot-bedrock-agent:latest --format '{{.Id}}'\`, - { encoding: 'utf-8' }, - ).trim(), + buildContexts: { + workspace: workspaceRoot, + }, + extraHash: FileSystem.fingerprint( + path.join(workspaceRoot, 'dist/apps/test-project/bundle-arm'), + ), }, ); @@ -97,6 +106,7 @@ exports[`py#strands-agent generator > should match snapshot for BedrockAgentCore "export * from './app.js'; export * from './checkov.js'; export * from './runtime-config.js'; +export * from './utils.js'; " `; diff --git a/packages/nx-plugin/src/py/strands-agent/generator.spec.ts b/packages/nx-plugin/src/py/strands-agent/generator.spec.ts index ccd309d5e..fd50e0ee4 100644 --- a/packages/nx-plugin/src/py/strands-agent/generator.spec.ts +++ b/packages/nx-plugin/src/py/strands-agent/generator.spec.ts @@ -293,8 +293,8 @@ dev-dependencies = [] 'bundle-arm', ); - // Check that build target depends on docker - expect(projectConfig.targets.build.dependsOn).toContain('docker'); + // For CDK, build target should not depend on docker (CDK builds via buildContexts) + expect(projectConfig.targets.build.dependsOn).not.toContain('docker'); }); it('should generate strands agent with BedrockAgentCoreRuntime and custom name', async () => { @@ -458,7 +458,7 @@ dev-dependencies = [] 'packages/common/constructs/src/app/agents/my-agent/my-agent.ts', 'utf-8', ); - expect(agentConstruct).toContain('docker inspect my-scope-my-agent:latest'); + expect(agentConstruct).toContain('buildContexts'); }); it('should handle Python bundle target configuration for BedrockAgentCoreRuntime', async () => { @@ -550,8 +550,8 @@ dev-dependencies = [] expect(projectConfig.targets.docker).toBeDefined(); expect(projectConfig.targets.docker.dependsOn).toContain(dockerTargetName); - // Check that build target depends on docker - expect(projectConfig.targets.build.dependsOn).toContain('docker'); + // For CDK, build target should not depend on docker (CDK builds via buildContexts) + expect(projectConfig.targets.build.dependsOn).not.toContain('docker'); }); it('should match snapshot for generated files', async () => { diff --git a/packages/nx-plugin/src/py/strands-agent/generator.ts b/packages/nx-plugin/src/py/strands-agent/generator.ts index 34836e1e9..0aa59865d 100644 --- a/packages/nx-plugin/src/py/strands-agent/generator.ts +++ b/packages/nx-plugin/src/py/strands-agent/generator.ts @@ -131,9 +131,13 @@ export const pyStrandsAgentGenerator = async ( { overwriteStrategy: OverwriteStrategy.KeepExisting }, ); + // Add shared constructs + const iacProvider = await resolveIacProvider(tree, options.iacProvider); + await sharedConstructsGenerator(tree, { iacProvider }); + const dockerTargetName = `${agentTargetPrefix}-docker`; - // Add a docker target specific to this MCP server + // Add a docker target specific to this agent project.targets[dockerTargetName] = { cache: true, executor: 'nx:run-commands', @@ -147,17 +151,20 @@ export const pyStrandsAgentGenerator = async ( }; addDependencyToTargetIfNotPresent(project, 'docker', dockerTargetName); - addDependencyToTargetIfNotPresent(project, 'build', 'docker'); - // Add shared constructs - const iacProvider = await resolveIacProvider(tree, options.iacProvider); - await sharedConstructsGenerator(tree, { iacProvider }); + // For Terraform, the docker image must be pre-built before deploy. + // For CDK, the image is built via DockerImageAsset with buildContexts. + if (iacProvider !== 'CDK') { + addDependencyToTargetIfNotPresent(project, 'build', 'docker'); + } // Add the construct to deploy the agent await addAgentInfra(tree, { agentNameKebabCase: name, agentNameClassName, dockerImageTag, + dockerfileDir: targetSourceDir, + bundleOutputDir, iacProvider, projectName: project.name, }); diff --git a/packages/nx-plugin/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap b/packages/nx-plugin/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap index d8efc822f..607c4db82 100644 --- a/packages/nx-plugin/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +++ b/packages/nx-plugin/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap @@ -9,14 +9,14 @@ exports[`ts#mcp-server generator > should match snapshot for BedrockAgentCoreRun "export * from './app.js'; export * from './checkov.js'; export * from './runtime-config.js'; +export * from './utils.js'; " `; exports[`ts#mcp-server generator > should match snapshot for BedrockAgentCoreRuntime generated constructs files > mcp-server-construct.ts 1`] = ` -"import { Lazy, Names } from 'aws-cdk-lib'; +"import { FileSystem, Lazy, Names } from 'aws-cdk-lib'; import { Platform } from 'aws-cdk-lib/aws-ecr-assets'; import { Construct } from 'constructs'; -import { execSync } from 'child_process'; import * as path from 'path'; import * as url from 'url'; import { @@ -26,6 +26,7 @@ import { RuntimeProps, } from '@aws-cdk/aws-bedrock-agentcore-alpha'; import { RuntimeConfig } from '../../../core/runtime-config.js'; +import { findWorkspaceRoot } from '../../../core/utils.js'; export type SnapshotBedrockServerProps = Omit< RuntimeProps, @@ -45,14 +46,23 @@ export class SnapshotBedrockServer extends Construct { const rc = RuntimeConfig.ensure(this); - this.dockerImage = AgentRuntimeArtifact.fromAsset( + const workspaceRoot = findWorkspaceRoot( path.dirname(url.fileURLToPath(new URL(import.meta.url))), + ); + + this.dockerImage = AgentRuntimeArtifact.fromAsset( + path.join(workspaceRoot, 'apps/test-project/src/snapshot-bedrock-server'), { platform: Platform.LINUX_ARM64, - extraHash: execSync( - \`docker inspect proj-snapshot-bedrock-server:latest --format '{{.Id}}'\`, - { encoding: 'utf-8' }, - ).trim(), + buildContexts: { + workspace: workspaceRoot, + }, + extraHash: FileSystem.fingerprint( + path.join( + workspaceRoot, + 'dist/apps/test-project/bundle/mcp/snapshot-bedrock-server', + ), + ), }, ); diff --git a/packages/nx-plugin/src/ts/mcp-server/generator.spec.ts b/packages/nx-plugin/src/ts/mcp-server/generator.spec.ts index 8baec2943..72b1a9a3f 100644 --- a/packages/nx-plugin/src/ts/mcp-server/generator.spec.ts +++ b/packages/nx-plugin/src/ts/mcp-server/generator.spec.ts @@ -609,21 +609,12 @@ describe('ts#mcp-server generator', () => { iacProvider: 'CDK', }); - expect( - tree.read( - 'packages/common/constructs/src/app/mcp-servers/my-server/Dockerfile', - 'utf-8', - ), - ).toContain('my-scope-my-server:latest'); - - // Check that the docker image tag is correctly generated in the MCP server construct + // Check that the CDK construct uses buildContexts const mcpServerConstruct = tree.read( 'packages/common/constructs/src/app/mcp-servers/my-server/my-server.ts', 'utf-8', ); - expect(mcpServerConstruct).toContain( - 'docker inspect my-scope-my-server:latest', - ); + expect(mcpServerConstruct).toContain('buildContexts'); }); it('should match snapshot for BedrockAgentCoreRuntime generated constructs files', async () => { diff --git a/packages/nx-plugin/src/ts/mcp-server/generator.ts b/packages/nx-plugin/src/ts/mcp-server/generator.ts index 97e6f1d63..f3e68ebfd 100644 --- a/packages/nx-plugin/src/ts/mcp-server/generator.ts +++ b/packages/nx-plugin/src/ts/mcp-server/generator.ts @@ -103,9 +103,7 @@ export const tsMcpServerGenerator = async ( esm, distDir, adotVersion: - TS_VERSIONS[ - '@aws/aws-distro-opentelemetry-node-autoinstrumentation' - ], + TS_VERSIONS['@aws/aws-distro-opentelemetry-node-autoinstrumentation'], }, { overwriteStrategy: OverwriteStrategy.KeepExisting }, ); @@ -134,6 +132,10 @@ export const tsMcpServerGenerator = async ( bundleOutputDir: joinPathFragments('mcp', name), }); + // Add shared constructs + const iacProvider = await resolveIacProvider(tree, options.iacProvider); + await sharedConstructsGenerator(tree, { iacProvider }); + const dockerTargetName = `${mcpTargetPrefix}-docker`; project.targets[dockerTargetName] = { @@ -146,11 +148,12 @@ export const tsMcpServerGenerator = async ( }; addDependencyToTargetIfNotPresent(project, 'docker', dockerTargetName); - addDependencyToTargetIfNotPresent(project, 'build', 'docker'); - // Add shared constructs - const iacProvider = await resolveIacProvider(tree, options.iacProvider); - await sharedConstructsGenerator(tree, { iacProvider }); + // For Terraform, the docker image must be pre-built before deploy. + // For CDK, the image is built via DockerImageAsset with buildContexts. + if (iacProvider !== 'CDK') { + addDependencyToTargetIfNotPresent(project, 'build', 'docker'); + } // Add the construct to deploy the mcp server await addMcpServerInfra(tree, { @@ -158,6 +161,8 @@ export const tsMcpServerGenerator = async ( mcpServerNameClassName, projectName: project.name, dockerImageTag, + dockerfileDir: targetSourceDir, + bundleOutputDir: joinPathFragments(distDir, 'bundle', 'mcp', name), iacProvider, }); } else { diff --git a/packages/nx-plugin/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap b/packages/nx-plugin/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap index 6493dc3d3..909e75b15 100644 --- a/packages/nx-plugin/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +++ b/packages/nx-plugin/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap @@ -1055,7 +1055,7 @@ exports[`react-website generator > Tanstack router integration > should generate "@cloudscape-design/board-components": "3.0.158", "@cloudscape-design/components": "3.0.1250", "@cloudscape-design/global-styles": "1.0.53", - "aws-cdk-lib": "2.244.0", + "aws-cdk-lib": "2.245.0", "constructs": "10.6.0", "react": "19.2.4", "react-dom": "19.2.4", @@ -1327,6 +1327,7 @@ exports[`react-website generator > Tanstack router integration > should generate export * from './app.js'; export * from './checkov.js'; export * from './runtime-config.js'; +export * from './utils.js'; " `; @@ -1768,6 +1769,23 @@ export class CloudfrontWebAcl extends Stack { " `; +exports[`react-website generator > Tanstack router integration > should generate website with no router correctly > packages/common/constructs/src/core/utils.ts 1`] = ` +"import * as fs from 'fs'; +import * as path from 'path'; + +export const findWorkspaceRoot = (startDir: string): string => { + let dir = startDir; + while (dir !== path.dirname(dir)) { + if (fs.existsSync(path.join(dir, 'nx.json'))) { + return dir; + } + dir = path.dirname(dir); + } + throw new Error('Could not find workspace root (nx.json)'); +}; +" +`; + exports[`react-website generator > Tanstack router integration > should generate website with no router correctly > packages/common/constructs/src/index.ts 1`] = ` "export * from './app/index.js'; export * from './core/index.js'; @@ -2646,7 +2664,7 @@ exports[`react-website generator > Tanstack router integration > should generate "@cloudscape-design/components": "3.0.1250", "@cloudscape-design/global-styles": "1.0.53", "@tanstack/react-router": "1.168.4", - "aws-cdk-lib": "2.244.0", + "aws-cdk-lib": "2.245.0", "constructs": "10.6.0", "react": "19.2.4", "react-dom": "19.2.4", @@ -2922,6 +2940,7 @@ exports[`react-website generator > Tanstack router integration > should generate export * from './app.js'; export * from './checkov.js'; export * from './runtime-config.js'; +export * from './utils.js'; " `; @@ -3363,6 +3382,23 @@ export class CloudfrontWebAcl extends Stack { " `; +exports[`react-website generator > Tanstack router integration > should generate website with router correctly > packages/common/constructs/src/core/utils.ts 1`] = ` +"import * as fs from 'fs'; +import * as path from 'path'; + +export const findWorkspaceRoot = (startDir: string): string => { + let dir = startDir; + while (dir !== path.dirname(dir)) { + if (fs.existsSync(path.join(dir, 'nx.json'))) { + return dir; + } + dir = path.dirname(dir); + } + throw new Error('Could not find workspace root (nx.json)'); +}; +" +`; + exports[`react-website generator > Tanstack router integration > should generate website with router correctly > packages/common/constructs/src/index.ts 1`] = ` "export * from './app/index.js'; export * from './core/index.js'; @@ -4584,6 +4620,7 @@ exports[`react-website generator > should generate shared constructs > common/co export * from './app.js'; export * from './checkov.js'; export * from './runtime-config.js'; +export * from './utils.js'; " `; @@ -4903,7 +4940,7 @@ exports[`react-website generator > should handle npm scope prefix correctly > sc "@cloudscape-design/components": "3.0.1250", "@cloudscape-design/global-styles": "1.0.53", "@tanstack/react-router": "1.168.4", - "aws-cdk-lib": "2.244.0", + "aws-cdk-lib": "2.245.0", "constructs": "10.6.0", "react": "19.2.4", "react-dom": "19.2.4", diff --git a/packages/nx-plugin/src/ts/react-website/cognito-auth/__snapshots__/generator.spec.ts.snap b/packages/nx-plugin/src/ts/react-website/cognito-auth/__snapshots__/generator.spec.ts.snap index 5ce006bc9..88f7fc1ec 100644 --- a/packages/nx-plugin/src/ts/react-website/cognito-auth/__snapshots__/generator.spec.ts.snap +++ b/packages/nx-plugin/src/ts/react-website/cognito-auth/__snapshots__/generator.spec.ts.snap @@ -81,6 +81,7 @@ exports[`cognito-auth generator > should generate files > identity-index 1`] = ` export * from './app.js'; export * from './checkov.js'; export * from './runtime-config.js'; +export * from './utils.js'; " `; @@ -299,5 +300,6 @@ exports[`cognito-auth generator > should update shared constructs index.ts > com export * from './app.js'; export * from './checkov.js'; export * from './runtime-config.js'; +export * from './utils.js'; " `; diff --git a/packages/nx-plugin/src/ts/strands-agent/__snapshots__/generator.spec.ts.snap b/packages/nx-plugin/src/ts/strands-agent/__snapshots__/generator.spec.ts.snap index f9e07968e..ef0affc1f 100644 --- a/packages/nx-plugin/src/ts/strands-agent/__snapshots__/generator.spec.ts.snap +++ b/packages/nx-plugin/src/ts/strands-agent/__snapshots__/generator.spec.ts.snap @@ -21,10 +21,9 @@ CMD [ "node", "--require", "@aws/aws-distro-opentelemetry-node-autoinstrumentati `; exports[`ts#strands-agent generator > should match snapshot for BedrockAgentCoreRuntime generated constructs files > agent-construct.ts 1`] = ` -"import { Lazy, Names } from 'aws-cdk-lib'; +"import { FileSystem, Lazy, Names } from 'aws-cdk-lib'; import { Platform } from 'aws-cdk-lib/aws-ecr-assets'; import { Construct } from 'constructs'; -import { execSync } from 'child_process'; import * as path from 'path'; import * as url from 'url'; import { @@ -34,6 +33,7 @@ import { RuntimeProps, } from '@aws-cdk/aws-bedrock-agentcore-alpha'; import { RuntimeConfig } from '../../../core/runtime-config.js'; +import { findWorkspaceRoot } from '../../../core/utils.js'; export type SnapshotBedrockAgentProps = Omit< RuntimeProps, @@ -49,14 +49,23 @@ export class SnapshotBedrockAgent extends Construct { const rc = RuntimeConfig.ensure(this); - this.dockerImage = AgentRuntimeArtifact.fromAsset( + const workspaceRoot = findWorkspaceRoot( path.dirname(url.fileURLToPath(new URL(import.meta.url))), + ); + + this.dockerImage = AgentRuntimeArtifact.fromAsset( + path.join(workspaceRoot, 'apps/test-project/src/snapshot-bedrock-agent'), { platform: Platform.LINUX_ARM64, - extraHash: execSync( - \`docker inspect proj-snapshot-bedrock-agent:latest --format '{{.Id}}'\`, - { encoding: 'utf-8' }, - ).trim(), + buildContexts: { + workspace: workspaceRoot, + }, + extraHash: FileSystem.fingerprint( + path.join( + workspaceRoot, + 'dist/apps/test-project/bundle/agent/snapshot-bedrock-agent', + ), + ), }, ); @@ -99,6 +108,7 @@ exports[`ts#strands-agent generator > should match snapshot for BedrockAgentCore "export * from './app.js'; export * from './checkov.js'; export * from './runtime-config.js'; +export * from './utils.js'; " `; diff --git a/packages/nx-plugin/src/ts/strands-agent/generator.spec.ts b/packages/nx-plugin/src/ts/strands-agent/generator.spec.ts index 1dd5a8802..1f556cccd 100644 --- a/packages/nx-plugin/src/ts/strands-agent/generator.spec.ts +++ b/packages/nx-plugin/src/ts/strands-agent/generator.spec.ts @@ -400,7 +400,7 @@ describe('ts#strands-agent generator', () => { 'packages/common/constructs/src/app/agents/my-agent/my-agent.ts', 'utf-8', ); - expect(agentConstruct).toContain('docker inspect my-scope-my-agent:latest'); + expect(agentConstruct).toContain('buildContexts'); }); it('should match snapshot for BedrockAgentCoreRuntime generated constructs files', async () => { diff --git a/packages/nx-plugin/src/ts/strands-agent/generator.ts b/packages/nx-plugin/src/ts/strands-agent/generator.ts index 9356cbf8d..1e5dcdd85 100644 --- a/packages/nx-plugin/src/ts/strands-agent/generator.ts +++ b/packages/nx-plugin/src/ts/strands-agent/generator.ts @@ -94,13 +94,15 @@ export const tsStrandsAgentGenerator = async ( distDir, name, adotVersion: - TS_VERSIONS[ - '@aws/aws-distro-opentelemetry-node-autoinstrumentation' - ], + TS_VERSIONS['@aws/aws-distro-opentelemetry-node-autoinstrumentation'], }, { overwriteStrategy: OverwriteStrategy.KeepExisting }, ); + // Add shared constructs + const iacProvider = await resolveIacProvider(tree, options.iacProvider); + await sharedConstructsGenerator(tree, { iacProvider }); + const dockerTargetName = `${agentTargetPrefix}-docker`; project.targets[dockerTargetName] = { @@ -113,17 +115,20 @@ export const tsStrandsAgentGenerator = async ( }; addDependencyToTargetIfNotPresent(project, 'docker', dockerTargetName); - addDependencyToTargetIfNotPresent(project, 'build', 'docker'); - // Add shared constructs - const iacProvider = await resolveIacProvider(tree, options.iacProvider); - await sharedConstructsGenerator(tree, { iacProvider }); + // For Terraform, the docker image must be pre-built before deploy. + // For CDK, the image is built via DockerImageAsset with buildContexts. + if (iacProvider !== 'CDK') { + addDependencyToTargetIfNotPresent(project, 'build', 'docker'); + } await addAgentInfra(tree, { agentNameKebabCase: name, agentNameClassName, projectName: project.name, dockerImageTag, + dockerfileDir: targetSourceDir, + bundleOutputDir: joinPathFragments(distDir, 'bundle', 'agent', name), iacProvider, }); } diff --git a/packages/nx-plugin/src/utils/__snapshots__/shared-constructs.spec.ts.snap b/packages/nx-plugin/src/utils/__snapshots__/shared-constructs.spec.ts.snap index 68997390f..a5039ac22 100644 --- a/packages/nx-plugin/src/utils/__snapshots__/shared-constructs.spec.ts.snap +++ b/packages/nx-plugin/src/utils/__snapshots__/shared-constructs.spec.ts.snap @@ -83,6 +83,7 @@ exports[`shared-constructs utils > sharedConstructsGenerator > should generate s "export * from './app.js'; export * from './checkov.js'; export * from './runtime-config.js'; +export * from './utils.js'; " `; @@ -272,6 +273,23 @@ export class RuntimeConfig extends Construct { " `; +exports[`shared-constructs utils > sharedConstructsGenerator > should generate shared constructs when they do not exist > packages/common/constructs/src/core/utils.ts 1`] = ` +"import * as fs from 'fs'; +import * as path from 'path'; + +export const findWorkspaceRoot = (startDir: string): string => { + let dir = startDir; + while (dir !== path.dirname(dir)) { + if (fs.existsSync(path.join(dir, 'nx.json'))) { + return dir; + } + dir = path.dirname(dir); + } + throw new Error('Could not find workspace root (nx.json)'); +}; +" +`; + exports[`shared-constructs utils > sharedConstructsGenerator > should generate shared constructs when they do not exist > packages/common/constructs/src/index.ts 1`] = ` "export * from './app/index.js'; export * from './core/index.js'; diff --git a/packages/nx-plugin/src/utils/agent-core-constructs/agent-core-constructs.ts b/packages/nx-plugin/src/utils/agent-core-constructs/agent-core-constructs.ts index 6cef6fdcc..f753bf6f2 100644 --- a/packages/nx-plugin/src/utils/agent-core-constructs/agent-core-constructs.ts +++ b/packages/nx-plugin/src/utils/agent-core-constructs/agent-core-constructs.ts @@ -29,6 +29,8 @@ export interface AddAgentCoreInfraProps { dockerImageTag: string; appDirectory: string; serverProtocol: 'MCP' | 'HTTP'; + dockerfileDir: string; + bundleOutputDir: string; } const addAgentCoreInfra = async ( @@ -167,6 +169,8 @@ export interface AddMcpServerInfraProps { mcpServerNameKebabCase: string; projectName: string; dockerImageTag: string; + dockerfileDir: string; + bundleOutputDir: string; } /** @@ -183,6 +187,8 @@ export const addMcpServerInfra = async ( projectName: options.projectName, appDirectory: 'mcp-servers', serverProtocol: 'MCP', + dockerfileDir: options.dockerfileDir, + bundleOutputDir: options.bundleOutputDir, iacProvider: options.iacProvider, }); }; @@ -192,6 +198,8 @@ export interface AddAgentInfraProps { agentNameKebabCase: string; projectName: string; dockerImageTag: string; + dockerfileDir: string; + bundleOutputDir: string; } /** @@ -208,6 +216,8 @@ export const addAgentInfra = async ( dockerImageTag: options.dockerImageTag, appDirectory: 'agents', serverProtocol: 'HTTP', + dockerfileDir: options.dockerfileDir, + bundleOutputDir: options.bundleOutputDir, iacProvider: options.iacProvider, }); }; diff --git a/packages/nx-plugin/src/utils/agent-core-constructs/files/cdk/app/agent-core/__nameKebabCase__/Dockerfile.template b/packages/nx-plugin/src/utils/agent-core-constructs/files/cdk/app/agent-core/__nameKebabCase__/Dockerfile.template deleted file mode 100644 index 03e135c1a..000000000 --- a/packages/nx-plugin/src/utils/agent-core-constructs/files/cdk/app/agent-core/__nameKebabCase__/Dockerfile.template +++ /dev/null @@ -1 +0,0 @@ -FROM <%- dockerImageTag %> \ No newline at end of file diff --git a/packages/nx-plugin/src/utils/agent-core-constructs/files/cdk/app/agent-core/__nameKebabCase__/__nameKebabCase__.ts.template b/packages/nx-plugin/src/utils/agent-core-constructs/files/cdk/app/agent-core/__nameKebabCase__/__nameKebabCase__.ts.template index 5af8018db..d72477d0b 100644 --- a/packages/nx-plugin/src/utils/agent-core-constructs/files/cdk/app/agent-core/__nameKebabCase__/__nameKebabCase__.ts.template +++ b/packages/nx-plugin/src/utils/agent-core-constructs/files/cdk/app/agent-core/__nameKebabCase__/__nameKebabCase__.ts.template @@ -1,7 +1,6 @@ -import { Lazy, Names } from 'aws-cdk-lib'; +import { FileSystem, Lazy, Names } from 'aws-cdk-lib'; import { Platform } from 'aws-cdk-lib/aws-ecr-assets'; import { Construct } from 'constructs'; -import { execSync } from 'child_process'; import * as path from 'path'; import * as url from 'url'; import { @@ -11,6 +10,7 @@ import { RuntimeProps, } from '@aws-cdk/aws-bedrock-agentcore-alpha'; import { RuntimeConfig } from '../../../core/runtime-config.js'; +import { findWorkspaceRoot } from '../../../core/utils.js'; export type <%- nameClassName %>Props = Omit< RuntimeProps, @@ -26,14 +26,20 @@ export class <%- nameClassName %> extends Construct { const rc = RuntimeConfig.ensure(this); - this.dockerImage = AgentRuntimeArtifact.fromAsset( + const workspaceRoot = findWorkspaceRoot( path.dirname(url.fileURLToPath(new URL(import.meta.url))), + ); + + this.dockerImage = AgentRuntimeArtifact.fromAsset( + path.join(workspaceRoot, '<%- dockerfileDir %>'), { platform: Platform.LINUX_ARM64, - extraHash: execSync( - `docker inspect <%- dockerImageTag %> --format '{{.Id}}'`, - { encoding: 'utf-8' }, - ).trim(), + buildContexts: { + workspace: workspaceRoot, + }, + extraHash: FileSystem.fingerprint( + path.join(workspaceRoot, '<%- bundleOutputDir %>'), + ), }, ); diff --git a/packages/nx-plugin/src/utils/files/common/constructs/src/core/index.ts.template b/packages/nx-plugin/src/utils/files/common/constructs/src/core/index.ts.template index 82e927bb1..5ec8b9a2f 100644 --- a/packages/nx-plugin/src/utils/files/common/constructs/src/core/index.ts.template +++ b/packages/nx-plugin/src/utils/files/common/constructs/src/core/index.ts.template @@ -1,3 +1,4 @@ export * from './app.js'; export * from './checkov.js'; -export * from './runtime-config.js'; \ No newline at end of file +export * from './runtime-config.js'; +export * from './utils.js'; \ No newline at end of file diff --git a/packages/nx-plugin/src/utils/files/common/constructs/src/core/utils.ts.template b/packages/nx-plugin/src/utils/files/common/constructs/src/core/utils.ts.template new file mode 100644 index 000000000..abf4651bf --- /dev/null +++ b/packages/nx-plugin/src/utils/files/common/constructs/src/core/utils.ts.template @@ -0,0 +1,13 @@ +import * as fs from 'fs'; +import * as path from 'path'; + +export const findWorkspaceRoot = (startDir: string): string => { + let dir = startDir; + while (dir !== path.dirname(dir)) { + if (fs.existsSync(path.join(dir, 'nx.json'))) { + return dir; + } + dir = path.dirname(dir); + } + throw new Error('Could not find workspace root (nx.json)'); +}; diff --git a/packages/nx-plugin/src/utils/versions.ts b/packages/nx-plugin/src/utils/versions.ts index e7bc4c2d3..61a7f304b 100644 --- a/packages/nx-plugin/src/utils/versions.ts +++ b/packages/nx-plugin/src/utils/versions.ts @@ -51,8 +51,8 @@ export const TS_VERSIONS = { '@vitest/ui': '4.1.1', aws4fetch: '1.0.20', 'aws-cdk': '2.1113.0', - 'aws-cdk-lib': '2.244.0', - '@aws-cdk/aws-bedrock-agentcore-alpha': '2.244.0-alpha.0', + 'aws-cdk-lib': '2.245.0', + '@aws-cdk/aws-bedrock-agentcore-alpha': '2.245.0-alpha.0', 'aws-xray-sdk-core': '3.12.0', constructs: '10.6.0', cors: '2.8.6', @@ -74,14 +74,14 @@ export const TS_VERSIONS = { react: '19.2.4', 'react-dom': '19.2.4', rimraf: '6.1.3', - 'rolldown': '1.0.0-rc.12', + rolldown: '1.0.0-rc.12', 'source-map-support': '0.5.21', tailwindcss: '4.2.2', '@tailwindcss/vite': '4.2.2', tsx: '4.21.0', 'lucide-react': '1.7.0', 'radix-ui': '1.4.3', - 'shadcn': '4.1.0', + shadcn: '4.1.0', 'tw-animate-css': '1.4.0', 'tailwind-merge': '3.5.0', vite: '7.3.1', @@ -107,8 +107,8 @@ export const PY_VERSIONS = { 'aws-lambda-powertools[parser]': '==3.26.0', 'aws-opentelemetry-distro': '==0.16.0', 'bedrock-agentcore': '==1.4.7', - 'boto3': '==1.42.76', - 'checkov': '==3.2.511', + boto3: '==1.42.76', + checkov: '==3.2.511', fastapi: '==0.135.2', 'fastapi[standard]': '==0.135.2', mcp: '==1.26.0',