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.
.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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Testing
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.