Skip to content

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

Description

@idofl

# Copy agent - Start

In the current structure of the Dockerfile, the build first creates a layer with the agent's code, and then creates another layer with the installed dependencies. This order of operations causes the build process to re-create the dependencies layer after every code change, even if the list of dependencies in the requirements.txt hasn't changed.

The correct order should be:

  1. copy only requirements.txt file.
  2. run pip install to download dependencies
  3. copy agent code

This should reduce the amount of time it takes to build container images when redeploying updated agent code, as long as the dependencies list doesn't change.

Activity

  1. mikemikimike commented on Aug 27, 2026

    @mikemikimike

    I'm preparing a focused fix for this issue: generate the Dockerfile by copying an agent's requirements.txt and installing those dependencies before copying the rest of the agent source, so source-only changes can reuse the dependency layer. I'll include a regression test that verifies the generated instruction order and will keep the change limited to the shared deployment template.

  2. added
    services[Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc
    on Aug 28, 2026
  3. llalitkumarrr commented on Sep 1, 2026

    @llalitkumarrr
    Collaborator

    Hello @idofl,

    Thank you for raising this issue and sharing your suggestion, #6928 implements this and we would greatly appreciate your feedback on it.

    We would also appreciate your inputs one edge case:

    By copying requirements.txt before the main codebase, pip install step will fail if requirements file references a local file dependency since that code has not been copied into the container yet.

    Hello @mikemikimike, Could you please share your inputs on above mentioned case as well?

  4. added
    request clarification[Status] The maintainer need clarification or more information from the author
    on Sep 1, 2026
  5. mikemikimike commented on Sep 1, 2026

    @mikemikimike

    Yes, I think this is a valid compatibility concern. The optimization should not make existing agent deployments fail. Since the previous Dockerfile copied the complete agent directory before running pip, local path/file dependencies could work there.
    I suggest preserving the old copy-before-install order when requirements.txt contains a local path dependency, and using the cache-friendly order otherwise. Please add regression tests for both cases. If local file dependencies are intentionally unsupported by adk deploy, please confirm so this can be documented as a deliberate breaking change.

  6. changed the issue type fromtoon Sep 1, 2026
  7. llalitkumarrr commented on Sep 16, 2026

    @llalitkumarrr
    Collaborator

    Hello @Jacksunwei,

    Could you please take a look at this?

  8. added
    needs review[Status] The PR/issue is awaiting review from the maintainer
    and removed
    request clarification[Status] The maintainer need clarification or more information from the author
    on Sep 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

needs review[Status] The PR/issue is awaiting review from the maintainerservices[Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions