Skip to content

fix(cli): preserve Docker dependency cache - #6928

Open
mikemikimike wants to merge 2 commits into
google:mainfrom
mikemikimike:fix/issue-6923
Open

fix(cli): preserve Docker dependency cache#6928
mikemikimike wants to merge 2 commits into
google:mainfrom
mikemikimike:fix/issue-6923

Conversation

@mikemikimike

@mikemikimike mikemikimike commented Aug 27, 2026

Copy link
Copy Markdown

Issue

Closes #6923.

Problem

The Dockerfile generated by adk deploy copied the complete agent source before installing the agent's requirements.txt. As a result, a source-only change invalidated the dependency layer and caused dependencies to be downloaded again.

Changes

  • Copy an agent's requirements.txt into its own Docker layer when the file is present.
  • Install agent dependencies before copying the remaining agent source.
  • Apply the ordering consistently to Cloud Run, Agent Engine, and GKE while preserving the existing no-requirements behavior.
  • Add a regression assertion for the generated Dockerfile instruction order.

Testing

  • .venv/Scripts/python.exe -m pytest tests/unittests/cli/utils/test_cli_deploy.py::test_to_agent_engine_happy_path tests/unittests/cli/utils/test_cli_deploy.py::test_to_gke_happy_path tests/unittests/cli/utils/test_cli_deploy_to_cloud_run.py::test_to_cloud_run_happy_path -q — 8 passed.
  • uvx --from pyink==25.12.0 pyink --check src/google/adk/cli/cli_deploy.py tests/unittests/cli/utils/test_cli_deploy_to_cloud_run.py — passed.
  • python -m ruff check src/google/adk/cli/cli_deploy.py tests/unittests/cli/utils/test_cli_deploy_to_cloud_run.py — passed.
  • python -m compileall -q src/google/adk/cli/cli_deploy.py — passed.
  • git diff --check — passed.
  • .venv/Scripts/python.exe -m pytest tests/unittests/cli/utils/test_cli_deploy.py tests/unittests/cli/utils/test_cli_deploy_to_cloud_run.py -q — 76 passed, with the 10 known failures described below.
  • mypy --config-file pyproject.toml src/google/adk/cli/cli_deploy.py --follow-imports=skip --ignore-missing-imports — 4 existing errors outside the changed lines.

Compatibility and known limitations

When no requirements.txt exists, no requirements copy or install step is emitted. The two affected deployment test files report 76 passed and 10 unrelated Windows failures because their tests mock shutil.rmtree with a one-argument lambda while Python 3.12 calls it with the onexc keyword; those tests were not modified. Mypy also reports four existing errors at lines 523, 1455, 1467, and 1702. The targeted deployment tests pass; no cloud credentials or external services are required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dockerfile should first copy requirements.txt and install dependencies before copying agent code

2 participants