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

Introduced include to filter files considered by watch #12584

Merged
merged 2 commits into from
Mar 3, 2025

Conversation

ndeloof
Copy link
Contributor

@ndeloof ndeloof commented Feb 25, 2025

What I did

Introduce include to only select a subset of files in source path for watch command.
Illustration example:

services:
  base:
    build:
      context: .
      dockerfile_inline: |
        FROM nginx
    develop:
      watch:
        - path: .
          include: "*.txt" # can also be an array
          action: rebuild

Related issue
closes #12544
see compose-spec/compose-go#747

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

@ndeloof ndeloof requested a review from a team as a code owner February 25, 2025 09:33
@ndeloof ndeloof requested a review from glours February 25, 2025 09:33
@ndeloof
Copy link
Contributor Author

ndeloof commented Feb 25, 2025

it would be nicer path can be set as a pattern, need to investigate we can support this

@ndeloof
Copy link
Contributor Author

ndeloof commented Feb 25, 2025

cc @jhrotko

@jhrotko
Copy link
Contributor

jhrotko commented Feb 25, 2025

@ndeloof so in this case can path be a pattern? In my PR I made this work.
In this case can you handle in this PR glob pattern for folders such as path: app/*/sub?

@ndeloof
Copy link
Contributor Author

ndeloof commented Feb 25, 2025

@jhrotko no it can't - this is intentional at this stage, as we need a base path to start collecting filesystem events, I'm investigating if we could get rid of this for better UX

About pattern for folder:

    develop:
      watch:
        - path: app
          include: "*/sub"
          action: rebuild

(see https://docs.docker.com/build/concepts/context/#syntax about actual pattern syntax)

@ndeloof ndeloof force-pushed the watch_include branch 3 times, most recently from 8ae65f8 to 8d9e288 Compare February 28, 2025 15:42
@ndeloof ndeloof enabled auto-merge (rebase) February 28, 2025 15:43
@ndeloof ndeloof disabled auto-merge February 28, 2025 15:43

Verified

This commit was signed with the committer’s verified signature.
ndeloof Nicolas De loof
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>

Verified

This commit was signed with the committer’s verified signature.
ndeloof Nicolas De loof
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
@ndeloof
Copy link
Contributor Author

ndeloof commented Mar 3, 2025

@glours added a dedicated e2e test

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

@ndeloof ndeloof merged commit 19571c2 into docker:main Mar 3, 2025
26 checks passed
@ndeloof ndeloof deleted the watch_include branch March 4, 2025 06:57
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.

Watch: Support Path Pattern Matching
3 participants