Skip to content

[BUG] Alpha watch should not rebuild when no x-develop option set #10570

@simonmallet

Description

@simonmallet

Description

First of all, thank you for developing this amazing feature! It will be great to support our mac + windows dev workstations without using volumes!

I have a docker-compose file with 12 services in it.
Most of them will use the watch feature, but not all of them.

For instance I have 2 services that do not mention "x-develop -> watch" in the service, yet when some files get updated, they are rebuilt automatically.

Rebuilding indexer-typescript, azfunc-all-v4-5 after changes were detected:

/Users/simonmallet/Sites/cbc/CMS-clone/typescript/current/dist/libs/rcgraph/src/lib/interfaces/withShortStoryTileTemplate.d.ts
/Users/simonmallet/Sites/cbc/CMS-clone/typescript/current/dist/libs/rcgraph/src/lib/valueObjects/rightType.js

My service definition: no mention of x-develop -> watch

azfunc-all-v4-5:
    build:
      context: ../typescript/current
      dockerfile: apps/content-notification/docker-local/Dockerfile.azfunc-all
    env_file:
      - .env
      - ../typescript/current/.env.local
    environment:
      environment: ${Environment}
      DeployedEnvironmentWithIndex: ${EnvironmentWithIndex}
    depends_on:
      - "mongo"
      - "elasticsearch"

I'd like to be able to use docker-compose alpha watch command and that it does NOT watch apps that do not mention the x-develop option. As an alternative, if I could specify x-develop -> watch and use a pre-defined option : none so that it knows not to watch or rebuild anything for this service.

When I build an app it writes a lot of files to the dist folder then the docker-compose alpha watch command goes in frenzy rebuilding everything forever using all the disk space.

Thanks!

Steps To Reproduce

  1. Have a docker-compose.yaml file with 2 projects where 1 of them has a x-develop watch and not the other:
scoop-ui-v3:
    image: scoop-ui-v3
    build:
      context: ../typescript/scoop-ui-v3
      dockerfile: Dockerfile.scoop-ui-v3-dev
    x-develop:
      watch:
         - action: sync
           path: "../typescript/scoop-ui-v3/"
           target: "/app/"
           ignore:
            - node_modules/
    command: yarn start

azfunc-all-v4-5:
    build:
      context: ../typescript/current
      dockerfile: apps/content-notification/docker-local/Dockerfile.azfunc-all
    env_file:
      - .env
      - ../typescript/current/.env.local
    environment:
      environment: ${Environment}
      DeployedEnvironmentWithIndex: ${EnvironmentWithIndex}
  1. Run: docker-compose up -d

  2. Run: docker-compose alpha watch

  3. Notice how the watch command is now listening on two projects instead of one

docker % docker-compose alpha watch
watch command is EXPERIMENTAL
watching /Users/simonmallet/Sites/CMS-clone/typescript/current
watching /Users/simonmallet/Sites/CMS-clone/typescript/scoop-ui-v3
  1. Modify any file under the project's build context where you did not specify a x-develop watch option. The change detected will be triggered anyway + it will rebuild the whole project!
change detected on /Users/simonmallet/Sites/CMS-clone/typescript/current/apps/scoop-api-v3/env/aq.env
Rebuilding azfunc-all-v4-5 after changes were detected:
  - /Users/simonmallet/Sites/CMS-clone/typescript/current/apps/scoop-api-v3/env/aq.env
[+] Building 1.2s (4/10)                                                                                                                                                                             
[+] Building 3.0s (4/10)                                                                                                                                                                             
 => [internal] load .dockerignore                                                                                                                                                               0.1s
 => => transferring context: 2B  
...

Compose Version

docker % docker compose version
Docker Compose version v2.17.3

docker % docker-compose version
Docker Compose version v2.17.3

Docker Environment

Client:
 Context:    desktop-linux
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.10.4
    Path:     /Users/simonmallet/.docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.17.3
    Path:     /Users/simonmallet/.docker/cli-plugins/docker-compose
  dev: Docker Dev Environments (Docker Inc.)
    Version:  v0.1.0
    Path:     /Users/simonmallet/.docker/cli-plugins/docker-dev
  extension: Manages Docker extensions (Docker Inc.)
    Version:  v0.2.19
    Path:     /Users/simonmallet/.docker/cli-plugins/docker-extension
  init: Creates Docker-related starter files for your project (Docker Inc.)
    Version:  v0.1.0-beta.4
    Path:     /Users/simonmallet/.docker/cli-plugins/docker-init
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
    Version:  0.6.0
    Path:     /Users/simonmallet/.docker/cli-plugins/docker-sbom
  scan: Docker Scan (Docker Inc.)
    Version:  v0.26.0
    Path:     /Users/simonmallet/.docker/cli-plugins/docker-scan
  scout: Command line tool for Docker Scout (Docker Inc.)
    Version:  v0.10.0
    Path:     /Users/simonmallet/.docker/cli-plugins/docker-scout

Server:
 Containers: 12
  Running: 12
  Paused: 0
  Stopped: 0
 Images: 12
 Server Version: 23.0.5
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 2806fc1057397dbaeefbea0e4e17bddfbd388f38
 runc version: v1.1.5-0-gf19387a
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 5.15.49-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 24.96GiB
 Name: docker-desktop
 ID: 5e62ab9b-0125-4cf0-a3b6-88999fa330bc
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal
 Registry: https://index.docker.io/v1/
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5555
  127.0.0.0/8
 Live Restore Enabled: false

Anything else?

Based on documentation: https://docs.docker.com/compose/file-watch/

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions