fix(harness): build and push harness Dockerfile via CDK asset (#927)#930
Closed
aryankhanna2004 wants to merge 1 commit intoaws:previewfrom
Closed
fix(harness): build and push harness Dockerfile via CDK asset (#927)#930aryankhanna2004 wants to merge 1 commit intoaws:previewfrom
aryankhanna2004 wants to merge 1 commit intoaws:previewfrom
Conversation
When a harness's harness.json sets "dockerfile" instead of "containerUri", the deploy pipeline previously silently dropped the field: the CDK stack created no image asset and the mapper omitted environmentArtifact from CreateHarness, so the harness came up without the user's custom container. See aws#927 for the repro. This change wires the dockerfile through end-to-end: - src/assets/cdk/bin/cdk.ts now forwards `dockerfile` and a resolved `codeLocation` (absolute harness directory) into the stack props. - src/assets/cdk/lib/cdk-stack.ts creates a linux/arm64 DockerImageAsset per harness that specifies a dockerfile and emits its imageUri as a per-harness CfnOutput named `ApplicationHarness<Pascal>ImageUri`. - src/cli/operations/deploy/imperative/deployers/harness-mapper.ts resolves that output from cdkOutputs and populates environmentArtifact.containerConfiguration.containerUri on the CreateHarness call. If the stack lacks the output (e.g. Docker was unavailable during synth), the mapper throws an actionable error instead of continuing silently. Behavior preserved when neither `dockerfile` nor `containerUri` is set (harness uses the managed default image). Explicit `containerUri` still takes precedence over a built image. Docker daemon with buildx linux/arm64 support is required at `agentcore deploy` time, matching the existing requirement for agent runtime Dockerfiles. Tests: - 3 new harness-mapper unit tests covering dockerfile + cdkOutputs, missing-output error, and containerUri precedence. - Updated asset snapshot tests for the new CDK files. - Verified end-to-end against a real project: * arm64 image built and pushed to cdk-hnb659fds-container-assets-<acct>-us-east-1. * ApplicationHarnessPptagentImageUri stack output emitted. * CreateHarness succeeded and harness reached READY. Fixes aws#927
This was referenced Apr 22, 2026
Author
|
Closing in favor of #929 (by @tejaskash), which landed a few minutes before this one and takes a cleaner approach. tl;dr: #929 reuses the existing agent Container build pipeline in the CLI ( Full comparison and rationale in #927 (comment). No action items for reviewers here — please move discussion to #929. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #927. When a harness's
harness.jsonsetsdockerfileinstead ofcontainerUri, the deploy pipeline previously dropped the field silently: the CDK stack produced no image asset and the mapper omittedenvironmentArtifactfromCreateHarness, so the harness came up without the user's custom container.This wires the dockerfile through end-to-end:
src/assets/cdk/bin/cdk.ts— forwardsdockerfileand a resolvedcodeLocation(absolute harness directory) into the stack props.src/assets/cdk/lib/cdk-stack.ts— creates alinux/arm64DockerImageAssetper harness that specifies a dockerfile, and emits itsimageUrias a per-harnessCfnOutputnamedApplicationHarness<Pascal>ImageUri.src/cli/operations/deploy/imperative/deployers/harness-mapper.ts— resolves that output fromcdkOutputsand populatesenvironmentArtifact.containerConfiguration.containerUrionCreateHarness. If the expected output is missing (e.g. Docker was unavailable during synth), the mapper now throws an actionable error instead of continuing silently.Behavior preserved when neither
dockerfilenorcontainerUriis set (harness uses the managed default image). ExplicitcontainerUristill takes precedence over a built image.A Docker daemon with
buildx linux/arm64support is required atagentcore deploytime, matching the existing requirement for agent runtime Dockerfiles.Test plan
npm run typecheckcleannpm run lint— 0 errors (all remaining warnings are pre-existing)harness-mapper.test.ts:dockerfileis setcontainerUristill wins over built imagenpm run test:update-snapshotsfor the affected CDK files)dockerfile: "Dockerfile",AWS_IAMauth, Claude Opus, browser + code interpreter, PPTX skill):cdk-hnb659fds-container-assets-<acct>-us-east-1ApplicationHarnessPptagentImageUriemittedCreateHarnessaccepted theenvironmentArtifact; harness reachedREADYFixes #927