Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
danielgafni opened this issue Dec 13, 2022 · 3 comments · May be fixed by #9666
Open

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

danielgafni opened this issue Dec 13, 2022 · 3 comments · May be fixed by #9666
Labels
kind/todo implementation task/epic for the skaffold team priority/p2 May take a couple of releases

Comments

@danielgafni
Copy link

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
@ericzzzzzzz
Copy link
Contributor

ericzzzzzzz commented Dec 13, 2022

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 ericzzzzzzz added kind/todo implementation task/epic for the skaffold team priority/p2 May take a couple of releases labels Dec 13, 2022
@nicknovitski
Copy link
Contributor

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"

@earlybard
Copy link

earlybard commented Jul 27, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/todo implementation task/epic for the skaffold team priority/p2 May take a couple of releases
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants