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

[BUG] watch watch's root even if that is not specified #11182

Closed
khalil-omer opened this issue Nov 12, 2023 · 5 comments · Fixed by compose-spec/compose-go#490
Closed

[BUG] watch watch's root even if that is not specified #11182

khalil-omer opened this issue Nov 12, 2023 · 5 comments · Fixed by compose-spec/compose-go#490
Assignees
Labels

Comments

@khalil-omer
Copy link

khalil-omer commented Nov 12, 2023

Description

When running a compose file like the below with docker compose watch in the context of a monorepo, the directory compose is run from is watched as well as the specific subdirectory. The expected behavior is for the path to be honored.

---
version: '3'
services:
  servicea:
    container_name: 'serviceA'
    build: ./apps/servicea
    develop:
      watch:
        - action: rebuild
        - path: ./apps/serviceA
    ports:
      - '4600:4600'

In fact, the output of the watch command includes
watching [/Users/khalil_work/repos/repoName /Users/khalil_work/repos/repoName/apps/serviceA]
which shows that the root is indeed being watched. I would expect only .apps/serviceA to be watched, not the root. Root defeats the purpose because then all containers with a watch config will be rebuilt based on any change in the repository.

The behavior is the same even if running docker compose watch servicea.

Compose Version

2.22

Docker Environment

Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.11.1
    Path:     /Users/khalil_work/.docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.22.0
    Path:     /Users/khalil_work/.docker/cli-plugins/docker-compose
@glours
Copy link
Contributor

glours commented Nov 16, 2023

Hello @khalil-omer
I can't reproduce with the latest versions of Compose v2.23.0 and v2.23.1, can you give a try to version v2.23.1 and let me know if you're still able to reproduce please?

@ndeloof ndeloof self-assigned this Nov 16, 2023
@ndeloof
Copy link
Contributor

ndeloof commented Nov 16, 2023

I can reproduce this issue, investigating...

@ndeloof
Copy link
Contributor

ndeloof commented Nov 16, 2023

got it: the root cause is your yaml declaration:

services:
  servicea:
    container_name: 'serviceA'
    build: ./apps/servicea
    develop:
      watch:
        - action: rebuild
        - path: ./apps/serviceA
```
this ones actually defines 2 watch rules, the first one with an action and no path (defaults to `.`), the second one with a path but no action.

should be:

```yaml
services:
  servicea:
    container_name: 'serviceA'
    build: ./apps/servicea
    develop:
      watch:
        - action: rebuild
           path: ./apps/serviceA
```

Anyway, watch should warn you about no action being configured, and imho `path` should be required.

@khalil-omer
Copy link
Author

Thank you @ndeloof and @glours!

@glours glours reopened this Nov 16, 2023
@glours
Copy link
Contributor

glours commented Nov 16, 2023

Re-opening as we should release compose-go first

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

Successfully merging a pull request may close this issue.

3 participants