Skip to content

Feature Request: Pass build params to docker/finch CLI #8656

Closed

Description

@royassis

Hey

I have a SAM application with multiple AWS lambda functions, that are image based.

Right now we run our CICD pipeline of a Jenkins server that runs on EC2.
All the intermediate docker layers are caches on the instance itself.

We are moving our Jenkins stack (workers and controller) from running on EC2 to EKS, so the layers won't be cached.
There is a solution for this with docker buildkit:
--cache-to and --cache-from.

What is a sutible solution for this when using AWS SAM?

Activity

  1. added
    stage/needs-triageAutomatically applied to new issues and PRs, indicating they haven't been looked at.
    on Feb 15, 2026
  2. reedham-aws commented on Feb 16, 2026

    @reedham-aws
    Contributor

    In #8661, I've added the framework for using docker buildkit. I believe once this is merged, it should be possible to use the --cache-to and --cache-from options with BuildKit via the DockerBuildArgs section in the Metadata of the template:

    Metadata:
      # ...
      DockerBuildArgs:
        CACHE_TO: !Ref CacheLocation

    I haven't thought too much about using other methods to achieve this, but I think this will work with your existing flow once merged.

  3. added and removed
    stage/needs-triageAutomatically applied to new issues and PRs, indicating they haven't been looked at.
    on Feb 16, 2026
  4. seshubaws commented on Mar 16, 2026

    @seshubaws
    Contributor

    Hi @royassis, #8661 will be available to use in the next release, coming later this week or early next week. Thank you for your patience!

  5. royassis commented on Mar 16, 2026

    @royassis
    Author

    Hi @royassis, #8661 will be available to use in the next release, coming later this week or early next week. Thank you for your patience!

    I'm very excited. Thank you.

  6. royassis commented on Mar 19, 2026

    @royassis
    Author

    Hey @seshubaws

    I tried to use cache-from and cache-to like so:

    Metadata:
      # ...
      DockerBuildArgs:
        CACHE_TO: !Ref CacheLocation
    

    When running sam build --use-buildkit it indeed finishes the build, but it seems that the layers might not be cached to ECR as I expected, I don't see any new images in my cache repo, after running sam build.

    When investigating with kiro, it mentioned this, so it might be related:

    But looking at the actual code in CLIBuildClient.build_image, all DockerBuildArgs entries are passed as --build-arg:

    if buildargs:
        for k, v in buildargs.items():
            cmd.extend(["--build-arg", f"{k}={v}"])

    So CACHE_TO and CACHE_FROM in DockerBuildArgs become --build-arg CACHE_TO=... and --build-arg CACHE_FROM=... — not --cache-to and --cache-from.

  7. seshubaws commented on Mar 20, 2026

    @seshubaws
    Contributor

    Hi @royassis, thanks for raising this! It seems we will have to implement a workaround for this so that the correct args get passed to DockerCLI.

  8. royassis commented on Mar 21, 2026

    @royassis
    Author

    Hi @royassis, thanks for raising this! It seems we will have to implement a workaround for this so that the correct args get passed to DockerCLI.

    Should we open a feature request?

  9. reedham-aws commented on Apr 11, 2026

    @reedham-aws
    Contributor

    Hello @royassis, I previously had misunderstood the difference between the build args that are passed to the Dockerfile and the build params that would be passed to the CLI.

    That being said, I'm opening up a new PR to give the functionality that you're asking for: #8913. It's still in draft right now as I fill out the functionality with more tests (as well as testing manually myself), but this should accomplish what you're looking for.

    Sorry this took so long!

  10. changed the title [-]Intermediate layer caching on EKS[/-] [+]Feature Request: Pass build params to docker/finch CLI[/+] on Apr 13, 2026
  11. reedham-aws commented on Apr 28, 2026

    @reedham-aws
    Contributor

    Hello @royassis, support for this was added in version 1.159.1. I believe your solution would look something like this:

        Metadata:
          Dockerfile: Dockerfile
          DockerContext: ./src
          DockerTag: latest
          DockerBuildExtraParams:
            - "--cache-to"
            - "user/app:cache ."
            - "--cache-from"
            - "user/app:cache ."
    

    Basically, you just need to provide a list of params that you want to use in the metadata. I'm going to close this as completed, but if you have more questions or issues just reopen it and I'll take another look.

  12. github-actions commented on Apr 28, 2026

    @github-actions
    Contributor

    ⚠️COMMENT VISIBILITY WARNING⚠️

    Comments on closed issues are hard for our team to see.
    If you need more assistance, please either tag a team member or open a new issue that references this one.
    If you wish to keep having a conversation with other community members under this issue feel free to do so.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions