Skip to content

direct_code_deploy ignores the project .dockerignore (only the bundled template is honored) #549

Description

@justjkk

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.pyCodeZipPackager._get_ignore_patterns() (local zip build)
  • services/codebuild.pyCodeBuildService._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

  1. agentcore configure a Python agent with deployment_type: direct_code_deploy.
  2. Add a large directory not in the bundled template (e.g. .claude/, data/, notebooks/) under source_path.
  3. Create a project-level .dockerignore containing that directory.
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions