devpod icon indicating copy to clipboard operation
devpod copied to clipboard

devpod build . always rebuilding when any file has changed

Open JeanPoll opened this issue 1 year ago • 2 comments

devpod build . always rebuilds when a any file is update in the repository and .devcontainer.json is in root of repo.

Failing setup: .devcontainer.json in root of repo
git clone repo cd repo devpod build . building devpod modify any file in the git repo devpod build . -> RESULTS IN REBUILINDG

The HASH is calculated on the root and taking all files into account. In this case it should just take .devcontainer.json

Working setup: devcontainer.json in subdirectory .devcontainer/devcontainer.json of repo
git clone repo devpod build . building devpod modify any file in the git repo devpod build . -> HASH did not change, so not rebuild.

The HASH is calculated on the .devcontainer directory and taking only .devcontainer.json into account, which is fine.

JeanPoll avatar Jul 18 '24 09:07 JeanPoll

Hi @JeanPoll, thanks for opening the issue. That's correct, DevPod resolves your build context, either manually set via build.context, the location of your Dockerfile or the root of the configuration (your case)). Any of the features or your Dockerfile could access files in your current build context which is why it's necessary to consider them as well.

We could think about a way of opting out of this behaviour though, or expose finer grained control over the prebuild tagging.

Any ideas on this?

related to this comment in #728

pascalbreuninger avatar Jul 19 '24 06:07 pascalbreuninger

Yes, good question ... it's not solvable unless you parse the dockerfile ... You can print a warning and encourage developers to place the devcontainer.json in the subdirectory .devcontainer.

JeanPoll avatar Jul 23 '24 13:07 JeanPoll

Hi @JeanPoll we've just released a new feature to reduce workspace start times. As a part of this work we have revisited the hashing function and now parses the compiled devcontainer's Dockerfile (with features) and reverse engineers a list of files that actually affect the build context and only hashes these files. I hope this helps your particular use case

bkneis avatar Sep 12 '24 06:09 bkneis