compose-go
compose-go copied to clipboard
feat: Add pattern matching and multiple paths to watch configuration
This PR enhances the watch configuration by introducing support for multiple paths and pattern matching under services.develop.watch.path. This update allows more flexibility in defining file-watching behavior for rebuild and restart actions.
Example:
1 │ services:
2 │ api:
3 │ image: avatars-api
4 │ build:
5 │ context: .
6 │ dockerfile: ./deploy/api.dockerfile
7 │ ports:
8 │ - 5734:80
9 │ develop:
10 │ watch:
11 │ - path: api/*.txt
12 │ action: rebuild
13 │ - path:
14 │ - api
15 │ - other
16 │ action: restart
This PoC is based on the request of #12544.
As discussed in this issue, given the restrictions of sync actions that require a 1:1 relation between path and target, I would propose to move this functionality to a new keyword paths that would be available for rebuild and restart actions only.
Related compose PR
While I can see some benefits having support for multiple values in path I can't see how this would help with https://github.com/docker/compose/issues/12544 and pattern support, can you please elaborate ?
While I can see some benefits having support for multiple values in
pathI can't see how this would help with docker/compose#12544 and pattern support, can you please elaborate ?
if you take a look at the original issue, the user is requesting for both changes. On a first approach I thought they were hand in hand however with the latest changes is a nice to have. Looking at some existing watch configurations a lot of users are repeating actions (ex.: rebuild) with a different path and I think it would be a nice addition to add multiple path to each action in order to reduce repetition in a compose file.
on https://github.com/docker/compose/issues/12544 user requests as "nice to have" some way to avoid duplication when multiple patterns must apply to the same action. The challenge we have then is to find a base path to receive filesystem events (we don't want to watch the whole filesystem !)
On https://github.com/docker/compose/pull/12584 I proposed to keep using a single path as base for such events, and dedicated include multi-value pattern so one can implement user-requested example as:
develop:
watch:
- action: rebuild
path: frontend
include:
- *.json
- *.js