Skip to content

Watch: Support Path Pattern Matching #12544

Closed
@davidgfitzgerald

Description

@davidgfitzgerald

Request

It would be nice if the watch path attribute behaved like the ignore attribute. For example, path could accept wildcards such as *.

At the very least it would help to have some more detail in the API documentation adding that (at least for the time being) pattern matching does not work on path.

Reference: https://docs.docker.com/reference/compose-file/develop/

Example

I would like the convenience of being able to do this:

services:
  frontend:
    build:
      context: ./frontend
      dockerfile: Dockerfile
    ports:
      - "5173:5173"
    develop:
        watch:
        - action: rebuild
          path: frontend/*.json
        - action: rebuild
          path: frontend/*.js

instead of the verbose (yet explicit):

services:
  frontend:
    build:
      context: ./frontend
      dockerfile: Dockerfile
    ports:
      - "5173:5173"
    develop:
        watch:
        - action: rebuild
          path: frontend/jsconfig.json
        - action: rebuild
          path: frontend/package-lock.json
        - action: rebuild
          path: frontend/package.json
        - action: rebuild
          path: frontend/eslint.config.js
        - action: rebuild
          path: frontend/svelte.config.js
        - action: rebuild
          path: frontend/tailwind.config.js
        - action: rebuild
          path: frontend/vite.config.js

Nice To Have

Bonus points for allowing multiple path entries in a single rebuild action:

services:
  frontend:
    build:
      context: ./frontend
      dockerfile: Dockerfile
    ports:
      - "5173:5173"
    develop:
        watch:
        - action: rebuild
          path: frontend/*.json frontend/*.js

Currently, passing a space separated list is silently interpreted as a single path. So, the below example (misleadingly) does not match frontend/package.json nor frontend/vite.config.js

        - action: rebuild
          path: frontend/package.json frontend/vite.config.js

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions