skaffold icon indicating copy to clipboard operation
skaffold copied to clipboard

`inputDigest()` build tagging policy doesn't take `Dockerfile` into account

Open danielgafni opened this issue 3 years ago • 3 comments

Expected behavior

Dockerfile should be taken into account when calculating the hash (even when outside the build context).

Actual behavior

The Dockerfile changes don't trigger a rebuild. In my case the Dockerfile is placed outside of the build context and is not included into the image.

Information

  • Skaffold version: v2.0.1
  • Operating system: Arch Linux
  • Installed via: pacman
  • Contents of skaffold.yaml:
apiVersion: skaffold/v3
kind: Config
metadata:
  name: my-name

build:
  tagPolicy:
    inputDigest: {}
  artifacts:
    - image: myImage
      context: context-dir
      docker:
        dockerfile: Dockerfile
  local:
    useBuildkit: true

Steps to reproduce the behavior

Make the following project structure:

.
├── Dockerfile
├── skaffold.yaml
└── context-dir
    └── file.txt
  • run skaffold build.
  • make an edit to Dockerfile
  • run skaffold build

danielgafni avatar Dec 13 '22 15:12 danielgafni

Hi @danielgafni thank you for the feedback, I think it make sense to take Dockerfile into account when computing hash even if the file is not in the build context

ericzzzzzzz avatar Dec 13 '22 15:12 ericzzzzzzz

It should also include changes to the buildArgs, even if those do not affect the file source dependencies. For example:

# Dockerfile
ARG node_version

FROM node:${node_version}

# ...
# skaffold.yaml
apiVersion: skaffold/v4beta1
kind: Config
metadata:
  name: example
build:
  artifacts:
  - image: example
    docker:
      buildArgs:
        node_version: "18.x.x"

nicknovitski avatar Jan 20 '23 20:01 nicknovitski

I've hit this same issue and have resorted to COPYing the Dockerfile to /tmp as the last stage of all of my images to force it to be part of the digest.

I am using inputDigest alongside tryImportMissing: true to remote cache skaffold images from my Docker registry. This has been a lot more reliable than any other method of remote caching for me.

earlybard avatar Jul 27 '23 05:07 earlybard