Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Watch initial sync #12047

Merged
merged 2 commits into from
Aug 9, 2024
Merged

Watch initial sync #12047

merged 2 commits into from
Aug 9, 2024

Conversation

jhrotko
Copy link
Contributor

@jhrotko jhrotko commented Aug 6, 2024

What I did
Introduce initial sync for sync and sync+restart actions in develop.watch configuration to solve issue when restarting watch - after a docker compose down - where the container no longer reflects previous changes. This behaviour is triggered when adding x-initialSync: true to a watch configuration. In order to make this work, it was needed to introduce Extensions to develop.watch.trigger in compose-go (check related PR below).

The initial sync will evaluate if any file in develop.watch.path was modified after the image creation time. It also ignores files from develop.watch.ignore paths and binded volumes.

Related issue

compose-go

fixes

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

@jhrotko jhrotko force-pushed the watch-initial-sync branch 2 times, most recently from b13abd1 to bb2d745 Compare August 6, 2024 10:05
@jhrotko jhrotko requested review from glours and ndeloof August 6, 2024 12:59
@jhrotko jhrotko self-assigned this Aug 6, 2024
@jhrotko jhrotko marked this pull request as ready for review August 6, 2024 13:09
@@ -574,3 +585,114 @@ func (s *composeService) pruneDanglingImagesOnRebuild(ctx context.Context, proje
}
}
}

func (s *composeService) initialSync(ctx context.Context, project *types.Project, service types.ServiceConfig, trigger types.Trigger, ignore watch.PathMatcher, syncer sync.Syncer) error {
dockerFileIgnore, err := watch.NewDockerPatternMatcher("/", []string{"Dockerfile", "*compose*.y*ml"})
Copy link
Contributor Author

@jhrotko jhrotko Aug 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a better way to handle all the compose.yaml variations pattern? For instance, tried compose.y[a]?ml but it did not work :(

@jhrotko jhrotko force-pushed the watch-initial-sync branch 3 times, most recently from fe051f9 to a60e6d9 Compare August 6, 2024 15:25
Signed-off-by: Joana Hrotko <joana.hrotko@docker.com>
@jhrotko jhrotko force-pushed the watch-initial-sync branch 2 times, most recently from d7bca14 to 8a90c06 Compare August 6, 2024 16:04
Signed-off-by: Joana Hrotko <joana.hrotko@docker.com>
}

// gets the image creation time for a service
func (s *composeService) imageCreatedTime(ctx context.Context, project *types.Project, serviceName string) (time.Time, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

possibly can be moved somewhere else more generic

Copy link
Contributor

@glours glours left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@glours glours merged commit 9c03797 into docker:main Aug 9, 2024
30 checks passed
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Aug 20, 2024
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [docker/compose](https://github.com/docker/compose) | patch | `v2.29.1` -> `v2.29.2` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>docker/compose (docker/compose)</summary>

### [`v2.29.2`](https://github.com/docker/compose/releases/tag/v2.29.2)

[Compare Source](docker/compose@v2.29.1...v2.29.2)

#### What's Changed

##### ✨ Improvements

-   docs: Update docker compose kill usage [(12041)](docker/compose#12041)
-   add `x-initSync` to watch to always provide initial [(12047)](docker/compose#12047)

##### 🐛 Fixes

-   Removes redundant condition from toAPIBuildOptions in build.go [(12009)](docker/compose#12009)
-   Fix stoping compose process for single container for file change on sync-restart action [(12014)](docker/compose#12014)

##### 🔧  Internal

-   bump golang `1.21.12` [(12017)](docker/compose#12017)
-   bump engine and cli to `v27.1.1`, buildx to `v0.16.1` [(12020)](docker/compose#12020)
-   bump engine and cli to `v27.1.2`, buildx to `v0.16.2`  [(12057)](docker/compose#12057)
-   remove all dependabot update MRs for OTel dependencies [(12006)](docker/compose#12006)
-   bump golang.org/x/sys `v0.22.0` and gofrs/flock `v0.12.1` [(12018)](docker/compose#12018)

#### New Contributors

-   [@&#8203;janbrasna](https://github.com/janbrasna) made their first contribution in [(12041)](docker/compose#12041)
-   [@&#8203;kapurm17](https://github.com/kapurm17) made their first contribution in [(12009)](docker/compose#12009)

**Full Changelog**: docker/compose@v2.29.1...v2.29.2

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40NDAuNyIsInVwZGF0ZWRJblZlciI6IjM3LjQ0MC43IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
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