Skaffold: Skaffold should push the built image with the latest tag on GoogleCloudBuild for faster cached builds

Created on 24 Jul 2019  路  5Comments  路  Source: GoogleContainerTools/skaffold

Expected behavior

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.

Actual behavior

Skaffold instructs GoogleCloudBuild to push the built image with the dirty tag, but not with the latest one.

Information

  • Skaffold version: v0.34.0
  • Operating system: MacOS 10.14.5
  • Contents of skaffold.yaml:
apiVersion: 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

Steps to reproduce the behavior

  1. Create a gcloud project
  2. Adjust the values of the skaffold.yml (e.g. my-project-id and my-image)
  3. Create a dockerfile with multiple layers
  4. skaffold dev
  5. Another skaffold dev so you can see that no layers are being re-used.
arebuild aretag builgcb help wanted kinfeature-request prioritp2

Most helpful comment

@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.

All 5 comments

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 :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.

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

GeertJohan picture GeertJohan  路  3Comments

nathanph picture nathanph  路  3Comments

strikeout picture strikeout  路  4Comments

heroic picture heroic  路  4Comments

nathkn picture nathkn  路  3Comments