Skip to content

support Buildx style --cache-from --cache-to options. #9932

@KowerKoint

Description

@KowerKoint

Description

Currently, --cache-from is interpreted as simple image reference, as this is only an exact format for Docker CLI without Buildx.

Now Buildx is almost standard builder for Docker. (installed by default with Docker Desktop) With Buildx, docker build is overwritten as an alias for docker buildx build. It supports rich option for caching. --cache-from accepts new format like type=registry,ref=user/app or type=local,src=path/to/code as well as previous one. Previous format option is regarded as registry cache. Moreover, Buildx supports --cache-to option for storing build caches.

Skaffold should acceepts these options.

Expected Behaivior

Accept skaffold.yaml below:

kind: Config
build:
  artifacts:
  - image: repository/name
    context: .
    docker:
      dockerfile: Dockerfile
      cacheFrom:
        - type=registry,ref=repository/name:latest
        - type=registry,ref=repository/name:latest-cache
      cacheTo:
        - type=registry,mode=max,ref=repository/name:latest-cache
  tagPolicy:
    sha256: {}
deploy:
  docker:
    images: [repository/name]

If the type is registry, pull the cache image to local before build as previous behaivior with simple image reference format.

Discussion

There is an option to specify the cache option in more structual format like below:

cacheFrom:
  - "golang:1.25"
  - type: registry
    ref: repository/name:latest
  - type: local
    src: path/to/cache

I think this is too complicated to validate format since acceptable keys differ by type.

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