Skip to content

Consolidate Container-only fields (dockerfile, buildContextPath, customDockerBuildArgs) into a containerConfig object #1703

Description

@aidandaly24

Summary

With #1284, Container agents now have three flat, Container-only fields on AgentEnvSpec: dockerfile, buildContextPath, and customDockerBuildArgs — plus cross-cutting "only allowed for Container builds" validators for each.

Both AgentEnvSpecSchema copies (CLI and @aws/agentcore-cdk) already carry a standing comment near the validators:

If adding more Container-specific fields, consider consolidating into a containerConfig object (see networkConfig pattern)

We've now hit that threshold. This tracks grouping them under a single optional object:

containerConfig?: {
  dockerfile?: string;
  buildContextPath?: string;
  customDockerBuildArgs?: Record<string, string>;
}

Benefits

  • One build !== 'Container' && data.containerConfig check instead of three per-field validators.
  • Future container-only options land inside containerConfig with no new cross-cutting validators.
  • Clearer grouping in the schema and docs (mirrors the existing networkConfig pattern).

Why it's deferred

This is a breaking schema change: it moves the already-shipped dockerfile field, touches every consumer, existing user agentcore.json files, and asset snapshots — and would have ballooned a contributor PR. Better as its own scoped change (with a migration note / back-compat shim if we want to keep accepting the flat form for a release).

Scope

  • CLI: src/schema/schemas/agent-env.ts (+ compacted mirror), consumers (packaging/container.ts, dev/config.ts, dev/container-dev-server.ts, deploy/preflight.ts), docs, snapshots.
  • @aws/agentcore-cdk: src/schema/schemas/agent-env.ts (+ compacted mirror), AgentEnvironment, ContainerSourceAsset.

Ref: review comment on #1284.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions