Summary
For direct_code_deploy, the source-packaging step ignores the project's own .dockerignore (and .gitignore). The ignore patterns are read only from the toolkit's bundled utils/runtime/templates/dockerignore.template, so there is no supported way to exclude project-specific directories from the uploaded code.zip. Any large directory not enumerated in the bundled template (e.g. .claude/, caches, data dirs, extra virtualenvs with non-standard names) gets packaged and uploaded.
Where
Two code paths compute the ignore list for direct code deploy, and both hardcode the bundled template:
utils/runtime/package.py → CodeZipPackager._get_ignore_patterns() (local zip build)
services/codebuild.py → CodeBuildService._parse_dockerignore() — docstring even states: "Always uses the dockerignore.template to ensure consistent file filtering during zip creation, regardless of source_path configuration."
def _get_ignore_patterns(self) -> List[str]:
# reads files("bedrock_agentcore_starter_toolkit")
# .joinpath("utils/runtime/templates/dockerignore.template")
# ...no project-level .dockerignore is consulted or merged
The .dockerignore that operations/runtime/configure.py / utils/runtime/container.py generate is only consumed by container deployments (Docker build context) — it is not read by the direct-code-deploy zip packagers.
There is no CLI flag (agentcore deploy --help has no ignore/exclude option), no .bedrock_agentcore.yaml key, and no environment variable to add patterns.
Impact
A repo that keeps a large directory under source_path which isn't in the bundled template gets it silently zipped and uploaded to S3. In our case a 1.6 GB directory (git worktrees under .claude/) would have been packaged; the effective source is ~9 MB. The only workaround today is editing the installed dockerignore.template inside site-packages, which is lost on every pip install / fresh venv.
Repro
agentcore configure a Python agent with deployment_type: direct_code_deploy.
- Add a large directory not in the bundled template (e.g.
.claude/, data/, notebooks/) under source_path.
- Create a project-level
.dockerignore containing that directory.
agentcore deploy → the directory is still included in code.zip (the project .dockerignore is ignored).
Proposed fix
Have _get_ignore_patterns() (and CodeBuildService._parse_dockerignore()) merge the project's .dockerignore (resolved from source_path / build context) on top of the bundled template defaults. This matches Docker's own behavior and the least-surprise expectation that a .dockerignore in the project root is honored.
Alternatively (or additionally): support an explicit ignore list in .bedrock_agentcore.yaml and/or an agentcore deploy --ignore <pattern> flag.
Environment
bedrock-agentcore-starter-toolkit 0.3.3 (behavior confirmed identical on the current main, 0.3.10 — _get_ignore_patterns is unchanged and still reads only the bundled template)
- Deployment type:
direct_code_deploy
- Python 3.13, macOS
Summary
For
direct_code_deploy, the source-packaging step ignores the project's own.dockerignore(and.gitignore). The ignore patterns are read only from the toolkit's bundledutils/runtime/templates/dockerignore.template, so there is no supported way to exclude project-specific directories from the uploadedcode.zip. Any large directory not enumerated in the bundled template (e.g..claude/, caches, data dirs, extra virtualenvs with non-standard names) gets packaged and uploaded.Where
Two code paths compute the ignore list for direct code deploy, and both hardcode the bundled template:
utils/runtime/package.py→CodeZipPackager._get_ignore_patterns()(local zip build)services/codebuild.py→CodeBuildService._parse_dockerignore()— docstring even states: "Always uses the dockerignore.template to ensure consistent file filtering during zip creation, regardless of source_path configuration."The
.dockerignorethatoperations/runtime/configure.py/utils/runtime/container.pygenerate is only consumed by container deployments (Docker build context) — it is not read by the direct-code-deploy zip packagers.There is no CLI flag (
agentcore deploy --helphas no ignore/exclude option), no.bedrock_agentcore.yamlkey, and no environment variable to add patterns.Impact
A repo that keeps a large directory under
source_pathwhich isn't in the bundled template gets it silently zipped and uploaded to S3. In our case a 1.6 GB directory (git worktrees under.claude/) would have been packaged; the effective source is ~9 MB. The only workaround today is editing the installeddockerignore.templateinsidesite-packages, which is lost on everypip install/ fresh venv.Repro
agentcore configurea Python agent withdeployment_type: direct_code_deploy..claude/,data/,notebooks/) undersource_path..dockerignorecontaining that directory.agentcore deploy→ the directory is still included incode.zip(the project.dockerignoreis ignored).Proposed fix
Have
_get_ignore_patterns()(andCodeBuildService._parse_dockerignore()) merge the project's.dockerignore(resolved fromsource_path/ build context) on top of the bundled template defaults. This matches Docker's own behavior and the least-surprise expectation that a.dockerignorein the project root is honored.Alternatively (or additionally): support an explicit ignore list in
.bedrock_agentcore.yamland/or anagentcore deploy --ignore <pattern>flag.Environment
bedrock-agentcore-starter-toolkit0.3.3 (behavior confirmed identical on the currentmain, 0.3.10 —_get_ignore_patternsis unchanged and still reads only the bundled template)direct_code_deploy