GoogleContainerTools / GoogleContainerTools/skaffold
support Buildx style `--cache-from` `--cache-to` options.
- Dominant language
- Go
- Stars
- 15.9k
- Forks
- 1.7k
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 10
Description
# Description
Currently, `--cache-from` is interpreted as simple image reference, as this is [only an exact format for Docker CLI without Buildx](https://docs.docker.jp/engine/reference/commandline/build.html).
Now Buildx is almost standard builder for Docker. ([installed by default with Docker Desktop](https://docs.docker.com/build/concepts/overview/#buildx)) With Buildx, [`docker build` is overwritten as an alias for `docker buildx build`](https://docs.docker.com/reference/cli/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](https://docs.docker.com/reference/cli/docker/buildx/build/#cache-from). Previous format option is regarded as registry cache. Moreover, Buildx supports [`--cache-to` option](https://docs.docker.com/reference/cli/docker/buildx/build/#cache-to) for storing build caches.
Skaffold should acceepts these options.
# Expected Behaivior
Accept `skaffold.yaml` below:
```yaml
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:
``` yaml
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`.
Contributor guide
Assessment
This issue has not been assessed yet.