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

feat: Add pattern matching and multiple paths to watch configuration #740

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jhrotko
Copy link
Collaborator

@jhrotko jhrotko commented Feb 17, 2025

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

@jhrotko jhrotko added the enhancement New feature or request label Feb 17, 2025
@jhrotko jhrotko requested review from ndeloof and glours February 17, 2025 11:40
@jhrotko jhrotko self-assigned this Feb 17, 2025
@jhrotko jhrotko force-pushed the feature-wild-star-watch-path branch from 44b96f9 to b0bb892 Compare February 17, 2025 11:48
@jhrotko jhrotko marked this pull request as ready for review February 17, 2025 11:51
@ndeloof
Copy link
Collaborator

ndeloof commented Feb 21, 2025

While I can see some benefits having support for multiple values in path I can't see how this would help with docker/compose#12544 and pattern support, can you please elaborate ?

@jhrotko jhrotko force-pushed the feature-wild-star-watch-path branch from 9ce61ad to ffa8777 Compare February 25, 2025 15:40
Signed-off-by: Joana Hrotkó <joana.hrotko@gmail.com>
Signed-off-by: Joana Hrotkó <joana.hrotko@gmail.com>
@jhrotko jhrotko force-pushed the feature-wild-star-watch-path branch from ffa8777 to 15ccb87 Compare February 25, 2025 15:45
@jhrotko
Copy link
Collaborator Author

jhrotko commented Feb 25, 2025

While I can see some benefits having support for multiple values in path I 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.

Signed-off-by: Joana Hrotkó <joana.hrotko@gmail.com>
@jhrotko jhrotko force-pushed the feature-wild-star-watch-path branch from 15ccb87 to 07d331d Compare February 25, 2025 15:51
@jhrotko jhrotko changed the title feature: Add pattern matching and multiple paths to watch configuration feat: Add pattern matching and multiple paths to watch configuration Feb 25, 2025
@ndeloof
Copy link
Collaborator

ndeloof commented Feb 25, 2025

on docker/compose#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 docker/compose#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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants