Skip to content

feat: add custom dockerfile support for Container agent builds#783

Merged
aidandaly24 merged 4 commits intoaws:mainfrom
aidandaly24:feat/custom-dockerfile
Apr 7, 2026
Merged

feat: add custom dockerfile support for Container agent builds#783
aidandaly24 merged 4 commits intoaws:mainfrom
aidandaly24:feat/custom-dockerfile

Conversation

@aidandaly24
Copy link
Copy Markdown
Contributor

@aidandaly24 aidandaly24 commented Apr 7, 2026

Summary

Add an optional dockerfile field to Container agent configuration, allowing users to specify a custom Dockerfile name (e.g. Dockerfile.gpu) instead of the default Dockerfile. This threads the new field through every layer: schema validation, CLI wizard, dev server, deploy preflight, and packaging.

Screenshots

Advanced settings multi-select with "Custom Dockerfile" option:

advanced-settings advanced-settings-selected

Dockerfile path input step:

dockerfile-path-input

Changes

Schema

File Change
src/schema/schemas/agent-env.ts Add dockerfile field with filename regex validation
src/schema/llm-compacted/agentcore.ts Add dockerfile to compacted schema

CLI Wizard (TUI)

File Change
src/cli/tui/screens/generate/types.ts Add dockerfile to advanced settings types
src/cli/tui/screens/generate/useGenerateWizard.ts Add Dockerfile step logic and advanced option
src/cli/tui/screens/generate/GenerateWizardUI.tsx Render Dockerfile input step in wizard
src/cli/tui/screens/agent/AddAgentScreen.tsx Thread dockerfile through add-agent flow
src/cli/tui/screens/agent/types.ts Add dockerfile to agent config types
src/cli/tui/screens/agent/useAddAgent.ts Handle dockerfile copy and config writing
src/cli/tui/screens/create/useCreateFlow.ts Pass dockerfile through create flow

Dev Server

File Change
src/cli/operations/dev/config.ts Include dockerfile in container dev config
src/cli/operations/dev/container-dev-server.ts Pass dockerfile to docker build command

Deploy & Packaging

File Change
src/cli/operations/deploy/preflight.ts Validate custom dockerfile exists before deploy
src/cli/operations/agent/generate/schema-mapper.ts Map dockerfile field to agent config
src/lib/packaging/container.ts Pass dockerfile to container build
src/lib/constants.ts Add getDockerfilePath() with path traversal guard

Tests (64 new/updated)

File Tests Added
src/schema/schemas/__tests__/agent-env.test.ts Schema validation (valid names, rejection, CodeZip)
src/cli/operations/deploy/__tests__/preflight-container.test.ts Preflight dockerfile existence check
src/cli/operations/dev/__tests__/config.test.ts Dev server dockerfile config threading
src/lib/packaging/__tests__/container.test.ts Container packaging with custom dockerfile
src/lib/__tests__/constants.test.ts getDockerfilePath + path traversal rejection
src/cli/tui/screens/generate/__tests__/useGenerateWizard.test.tsx Wizard step logic
src/cli/tui/screens/agent/__tests__/computeByoSteps.test.ts BYO agent step computation

Security

getDockerfilePath() rejects any dockerfile name containing /, \, or .. to prevent path traversal attacks. The Zod schema additionally enforces ^[a-zA-Z0-9][a-zA-Z0-9._-]*$.

Test plan

  • Unit tests: npm test — 3203 passed (5 pre-existing failures in JWT gateway, unrelated)
  • Lint: eslint, prettier, secretlint, typecheck all pass
  • E2E deploy: Container agent with Dockerfile.gpu deployed to AWS, status READY, invoke returns response
  • E2E deploy: Container agent with default Dockerfile deployed, status READY, invoke returns response
  • Dev server (TUI harness): agentcore dev builds from Dockerfile.gpu — confirmed in Docker build log
  • Dev server (TUI harness): agentcore dev with no dockerfile field builds from Dockerfile — confirmed
  • Create wizard (TUI harness): "Custom Dockerfile" appears in Advanced settings for Container builds
  • Create wizard (TUI harness): Dockerfile step shows in breadcrumb, validates input, displays in confirmation
  • Validation edge cases: various dockerfile names, CodeZip rejection, path traversal rejection

Related

Add an optional `dockerfile` field to Container agent configuration,
allowing users to specify a custom Dockerfile name (e.g. Dockerfile.gpu)
instead of the default "Dockerfile".

Changes across all layers:
- Schema: Add dockerfile field to AgentEnvSpecSchema with filename validation
- CLI wizard: Add "Custom Dockerfile" option to Advanced settings multi-select,
  with dedicated Dockerfile input step in the breadcrumb wizard
- Dev server: Thread dockerfile through container config to docker build
- Deploy preflight: Validate custom dockerfile exists before deploy
- Packaging: Pass dockerfile to container build commands
- Security: getDockerfilePath rejects path traversal (/, \, ..)
- Tests: 64 new/updated tests across schema, preflight, dev config,
  packaging, wizard, and constants

Constraint: Dockerfile must be a filename only (no path separators)
Rejected: Accept full paths | path traversal security risk
Rejected: Auto-copy Dockerfile on create | users manage their own Dockerfiles
Confidence: high
Scope-risk: moderate
Not-tested: Interactive TUI tested manually via TUI harness (not in CI)
@aidandaly24 aidandaly24 requested a review from a team April 7, 2026 16:13
@github-actions github-actions bot added the size/xl PR size: XL label Apr 7, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

Package Tarball

aws-agentcore-0.6.0.tgz

How to install

npm install https://github.com/aws/agentcore-cli/releases/download/pr-783-tarball/aws-agentcore-0.6.0.tgz

- Remove unused ADVANCED_GROUP_LABELS constant (dead code)
- Remove unnecessary export on DOCKERFILE_NAME_REGEX
- Fix stale `steps` dependency in useGenerateWizard setAdvanced callback
- Trim computeByoSteps.test.ts to dockerfile-only tests (remove 11 tests
  for pre-existing behavior unchanged by this PR)
- Remove redundant "uses default Dockerfile" tests that duplicate existing
  coverage in preflight, config, and container packager test files
- Consolidate shell metacharacter it.each from 5 cases to 1 representative

Confidence: high
Scope-risk: narrow
@github-actions github-actions bot added size/xl PR size: XL and removed size/xl PR size: XL labels Apr 7, 2026
When a custom dockerfile is configured (e.g. Dockerfile.gpu), the
renderer was still copying the default template Dockerfile into the
agent directory, leaving an unused file alongside the custom one.

Thread the dockerfile config through AgentRenderConfig and use a new
exclude option on copyAndRenderDir to skip the template Dockerfile
when a custom one is specified. The .dockerignore is still scaffolded.

Constraint: copyAndRenderDir is a shared utility used by all renderers
Rejected: Delete template after render | user requested option A (don't create)
Confidence: high
Scope-risk: narrow
Replace the TextInput with PathInput for Dockerfile selection in both
the BYO add-agent and Generate wizard flows. This gives users a real
file browser with directory navigation and existence validation on
submit, matching the UX pattern used by the policy file picker.

BYO flow: PathInput scoped to the agent's code directory so users
browse their existing files and pick a Dockerfile.

Generate flow: PathInput scoped to cwd so users browse the filesystem
to find a Dockerfile to copy into the new project.

Added allowEmpty and emptyHelpText props to PathInput so users can
press Enter to use the default Dockerfile.

Constraint: PathInput is a shared component used by policy and import screens
Rejected: Soft warning on TextInput | user preferred real file picker like policy
Confidence: high
Scope-risk: narrow
@github-actions github-actions bot added size/xl PR size: XL and removed size/xl PR size: XL labels Apr 7, 2026
Copy link
Copy Markdown
Contributor

@jesseturner21 jesseturner21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@aidandaly24 aidandaly24 merged commit cdd5a15 into aws:main Apr 7, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/xl PR size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants