Skip to content

watch: build & launch the project at start#10957

Merged
milas merged 1 commit intodocker:mainfrom
milas:up-on-watch
Sep 7, 2023
Merged

watch: build & launch the project at start#10957
milas merged 1 commit intodocker:mainfrom
milas:up-on-watch

Conversation

@milas
Copy link
Copy Markdown
Contributor

@milas milas commented Aug 31, 2023

What I did
The alpha watch command current "attaches" to an already-running Compose project, so it's necessary to run something like docker compose up --wait first.

Now, we'll do the equivalent of an up --build before starting the watch, so that we know the project is up-to-date and running.

Additionally, unlike an interactive up, the services are not stopped when watch exits (e.g. via Ctrl-C). This prevents the need to start from scratch each time the command is run - if some services are already running and up-to-date, they can be used as-is. A down can always be used to destroy everything, and we can consider introducing a flag like --down-on-exit to watch or changing the default.

NOTE: This requires #10956, so it won't even build until that's merged 😬

Related issue
https://docker.atlassian.net/browse/ENV-286

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

@milas milas requested a review from a team August 31, 2023 21:04
@milas milas self-assigned this Aug 31, 2023
@milas milas requested review from StefanScherer, glours, laurazard, ndeloof, nicksieger and ulyssessouza and removed request for a team August 31, 2023 21:04
@milas milas marked this pull request as ready for review September 5, 2023 20:36
@milas
Copy link
Copy Markdown
Contributor Author

milas commented Sep 5, 2023

This is rebased and good to go!

(Sidenote: IntelliJ's local history feature saved me because I accidentally deleted most of this when splitting it from #10956 😬)

@codecov
Copy link
Copy Markdown

codecov Bot commented Sep 5, 2023

Codecov Report

Patch coverage: 42.81% and project coverage change: -0.71% ⚠️

Comparison is base (aeb835a) 58.30% compared to head (513dc99) 57.59%.
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10957      +/-   ##
==========================================
- Coverage   58.30%   57.59%   -0.71%     
==========================================
  Files         124      127       +3     
  Lines       10912    11068     +156     
==========================================
+ Hits         6362     6375      +13     
- Misses       3922     4061     +139     
- Partials      628      632       +4     
Files Changed Coverage Δ
pkg/api/api.go 28.84% <ø> (ø)
pkg/compose/publish.go 0.00% <0.00%> (ø)
pkg/remote/git.go 1.69% <0.00%> (-8.31%) ⬇️
pkg/remote/oci.go 2.46% <2.46%> (ø)
cmd/compose/events.go 28.20% <16.66%> (ø)
cmd/compose/watch.go 20.63% <17.07%> (-10.40%) ⬇️
cmd/compose/kill.go 48.14% <25.00%> (ø)
cmd/compose/push.go 41.37% <25.00%> (ø)
cmd/compose/viz.go 51.02% <25.00%> (ø)
cmd/compose/config.go 33.95% <28.57%> (-0.19%) ⬇️
... and 27 more

... and 8 files with indirect coverage changes

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

The `alpha watch` command current "attaches" to an already-running
Compose project, so it's necessary to run something like
`docker compose up --wait` first.

Now, we'll do the equivalent of an `up --build` before starting the
watch, so that we know the project is up-to-date and running.

Additionally, unlike an interactive `up`, the services are not stopped
when `watch` exits (e.g. via `Ctrl-C`). This prevents the need to start
from scratch each time the command is run - if some services are already
running and up-to-date, they can be used as-is. A `down` can always be
used to destroy everything, and we can consider introducing a flag like
`--down-on-exit` to `watch` or changing the default.

Signed-off-by: Milas Bowman <[email protected]>
@milas milas merged commit d7b0b2b into docker:main Sep 7, 2023
@milas milas deleted the up-on-watch branch September 7, 2023 17:27
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.

2 participants