GoogleContainerTools / kaniko

Build Container Images In Kubernetes
Apache License 2.0
14.73k stars 1.43k forks source link

Multistage builds doesn't always bust the cache correctly #845

Closed fredr closed 4 years ago

fredr commented 4 years ago

Actual behavior When copying files from an other stage and then chowning the files, the chown command will be cached even though the files being copied have change, causing the cache to overwrite all changes.

Expected behavior I would expect the cache to be busted after the COPY-command if the files have changed.

To Reproduce Steps to reproduce the behavior:

  1. Build the Dockerfile provided in this ticket with kaniko, and run:

    $ docker run -it --rm gcr.io/project-xyz/app:hash cat myfile
    VALUE
  2. change the content of myfile to anything else and rerun step 1. It will still return VALUE

Additional Information The Dockerfile:

FROM alpine:3.10 AS builder

WORKDIR /source
COPY . .

FROM alpine:3.10

WORKDIR /target
COPY --from=builder /source .

RUN chown -R 1000:1000 .

The file beeing copied: myfile (content doesn't matter)

VALUE
fredr commented 4 years ago

noticed that this probably is a duplicate of #589

fredr commented 4 years ago

I've tested with the latest master (a675098b452d020bf678063a3ac2d3be84b0e545) and this seems to have been solved

cvgw commented 4 years ago

Thanks for verifying @fredr . Closing this issue but feel free to reopen if needed