dnephin / dobi

A build automation tool for Docker applications
https://dnephin.github.io/dobi/
Apache License 2.0
309 stars 36 forks source link

Root dockerfile/context always rebuilds because of .dobi directory #179

Closed tduffield closed 4 years ago

tduffield commented 4 years ago

I'm not sure if this is desired behavior, or something that is even fixable at this point, but this ate up my entire day so I wanted to document it for others that might run into the same issue.

If you use the default context (.), your image will always be marked as stale because the folder will be marked as modified by the previous build's .dobi file. There is then a "race condition" (in quotes because modtime always seems to win this race) between when your file is marked as modified, and the parent folder is marked as modified. The image file always wins, so it triggers this condition and marks the image as stale.

# Output gathered from a local build with additional logging
[DEBUG] [image:build myimage] myimage paths: %s[.]
[DEBUG] [image:build myimage] myimage modtime: %s2020-04-14 17:45:29.408252582 -0500 CDT
[DEBUG] [image:build myimage] myimage mtime: %s2020-04-14 17:45:29.59530919 -0500 CDT
[DEBUG] [image:build myimage] myimage Image record older than context
[DEBUG] [image:build myimage] myimage is stale

Luckily, Docker caching won't make this an expensive operation locally, but it can be very confusing when you're just learning the tool and figuring out how to use it in a CI pipeline where each task will be in a separate job, and you're very concerned why your depends and .dobi files aren't being respected as you expect.

It's possible this is an OS specific issue: I'm running MacOS 10.15.4. It might depend on how your OS handles updating the mtime of the file and its parent folder.

dnephin commented 4 years ago

Thank you for the bug report! I think this was recently fixed by #168, but I don't think there has been a release since then. I can try to put out a new release soon. If you are able to try with a build from master and confirm it is fixed it would be much appreciated!

tduffield commented 4 years ago

Since opening this issue I've found #168. The build above was based off master, so I'm not sure if #168 solved the issue or not. Going to try and dig in deeper.

tduffield commented 4 years ago

Found the issue. It was seeing modifications to the .git directory. I've verified locally, and have opened up a PR.