Skip to content

in watch mode force pull policy to build for services with both build and develop attributes - #11213

Merged
glours merged 1 commit into
docker:mainfrom
glours:watch-force-build-at-startup
Nov 22, 2023
Merged

glours merged 1 commit into
docker:mainfrom
glours:watch-force-build-at-startup

Conversation

@glours

@glours glours commented Nov 21, 2023

Copy link
Copy Markdown
Contributor

This default behaviour will force a rebuild of the service images at watch process startup and be sure containers will be in sync with the local source code

What I did
For each service target by watch process (with a develop configuration) force the pull policy to build to be sure they will be rebuild at watch startup

Related issue

(not mandatory) A picture of a cute animal, if possible in relation to what you did
image

@ndeloof

ndeloof commented Nov 21, 2023

Copy link
Copy Markdown
Contributor

LGTM
A forced-(re)build might take time even with cache (baking a cache-efficient Dockerfile is an art), so I wonder we should guard this by comparison between last modified time for watched files and image's creation date.

@codecov

codecov Bot commented Nov 21, 2023 •

Copy link
Copy Markdown

Codecov Report

Attention: 5 lines in your changes are missing coverage. Please review.

Comparison is base (0ab21a2) 56.83% compared to head (2ba5e4c) 56.82%.
Report is 1 commits behind head on main.

Files Patch % Lines
cmd/compose/watch.go 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11213      +/-   ##
==========================================
- Coverage   56.83%   56.82%   -0.01%     
==========================================
  Files         133      133              
  Lines       11486    11491       +5     
==========================================
+ Hits         6528     6530       +2     
- Misses       4321     4325       +4     
+ Partials      637      636       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

… and develop attributes

This default behaviour will force a rebuild of the service images at watch process startup and be sure containers will be in sync with the local source code

Signed-off-by: Guillaume Lours <[email protected]>
@glours
glours force-pushed the watch-force-build-at-startup branch from 0ba63da to 2ba5e4c Compare November 21, 2023 15:42
@glours

glours commented Nov 21, 2023

Copy link
Copy Markdown
Contributor Author

LGTM A forced-(re)build might take time even with cache (baking a cache-efficient Dockerfile is an art), so I wonder we should guard this by comparison between last modified time for watched files and image's creation date.

We have the --no-op flag to avoid building images for this, you think this may not be enough @ndeloof?

@milas

milas commented Nov 21, 2023

Copy link
Copy Markdown
Contributor

I agree with @ndeloof - that's something I've seen first-hand with Tilt, which has similar behavior. Some larger projects, even with efficient layer caching, could take a while just to run through and do context transfers etc.

That said, I do think that, even imperfect, this is a beneficial change, but we should look at using mtime (also imperfect) or other approaches to continue to refine the behavior

@glours
glours merged commit 587dba1 into docker:main Nov 22, 2023
@glours
glours deleted the watch-force-build-at-startup branch June 30, 2025 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants