Using skaffold with GoogleCloudBuild and a cacheFrom directive using the same image name, we expect skaffold to instruct GCB to push the built image not only with the dirty-... tag, but also with the latest tag so we can re-use the layers on consecutive builds.
Skaffold instructs GoogleCloudBuild to push the built image with the dirty tag, but not with the latest one.
v0.34.0MacOS 10.14.5apiVersion: skaffold/v1beta13
kind: Config
build:
artifacts:
- image: eu.gcr.io/my-project-id/my-image
context: .
docker:
dockerfile: Dockerfile
cacheFrom:
- eu.gcr.io/my-project-id/my-image
googleCloudBuild:
projectId: my-project-id
skaffold.yml (e.g. my-project-id and my-image)skaffold devskaffold dev so you can see that no layers are being re-used.Hi, if you put
cacheFrom:
- eu.gcr.io/my-project-id/my-image
with latest:
cacheFrom:
- eu.gcr.io/my-project-id/my-image:latest
as long as you have a latest tag in the registry it would work right?
@iasinDev The problem is that you have to manually push to the :latest tag each time a new image was built and pushed by skaffold, this is quite tedious.
What I would suggest is that skaffold should take care of that (maybe enabled/disabled via a setting in the skaffold.yml) so each time skaffold builds and pushes a new image, it will also be pushed as the latest image, that way the developer can enjoy cached builds.
Raising the priority, both because of the reactions, and because this seems like something we should sort out sooner than later. Thank you for raising this issue!
@iasinDev The problem is that you have to manually push to the
:latesttag each time a new image was built and pushed by skaffold, this is quite tedious.What I would suggest is that skaffold should take care of that (maybe enabled/disabled via a setting in the
skaffold.yml) so each time skaffold builds and pushes a new image, it will also be pushed as thelatestimage, that way the developer can enjoy cached builds.
Yeah, that's the thing for that reason I downgraded to use Skaffold 0.20; this version makes the double tag, it creates the tag of the new version and at the same time tag the same image also with the latest tag, I don't know how and why in the last versions it has lost this behaviour (or maybe can be set but I don't know how)
v0.20.0 fixes this because, skaffold created the build step with output as artifact.ImageName
https://github.com/GoogleContainerTools/skaffold/blob/v0.20.0/pkg/skaffold/build/gcb/desc.go#L53
vs now, its tag computed for the artifact.
https://github.com/GoogleContainerTools/skaffold/blob/5a9227ce7dfd9709547d5d2c7ad9f896ee74bafc/pkg/skaffold/build/gcb/buildpacks.go#L62
The easy way would be add image name also to the same line
Most helpful comment
@iasinDev The problem is that you have to manually push to the
:latesttag each time a new image was built and pushed by skaffold, this is quite tedious.What I would suggest is that skaffold should take care of that (maybe enabled/disabled via a setting in the
skaffold.yml) so each time skaffold builds and pushes a new image, it will also be pushed as thelatestimage, that way the developer can enjoy cached builds.