From 743730eff1dc067395a381781dd2945d6f8e608c Mon Sep 17 00:00:00 2001 From: Guillaume Lours <705411+glours@users.noreply.github.com> Date: Thu, 19 Oct 2023 10:01:03 +0200 Subject: [PATCH] Watch sync and restart action (#18463) * add sync+restart definition to watch documentation Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com> * align watch path, relative to project dir and not build context, with specification definition Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com> * add prerequistes for compose watch feature Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com> * Update content/compose/file-watch.md --------- Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com> Co-authored-by: Allie Sadler <102604716+aevesdocker@users.noreply.github.com> --- content/compose/file-watch.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/content/compose/file-watch.md b/content/compose/file-watch.md index faae364794..90e1889e8f 100644 --- a/content/compose/file-watch.md +++ b/content/compose/file-watch.md @@ -13,7 +13,7 @@ Use `watch` to automatically update and preview your running Compose services as For many projects, this allows for a hands-off development workflow once Compose is running, as services automatically update themselves when you save your work. `watch` adheres to the following file path rules: -* All paths are relative to the build context +* All paths are relative to the project directory * Directories are watched recursively * Glob patterns aren't supported * Rules from `.dockerignore` apply @@ -45,6 +45,14 @@ the `action`, additional fields might be accepted or required. Watch mode can be used with many different languages and frameworks. The specific paths and rules will vary project to project, but the concepts remain the same. +### Prerequisites + +In order to work properly, `watch` relies on common executables. Make sure your service image contains the following binaries: +* stat +* mkdir +* rmdir +* tar + ### `action` #### Sync @@ -64,6 +72,13 @@ The behavior is the same as running `docker compose up --build `. Rebuild is ideal for compiled languages or as fallbacks for modifications to particular files that require a full image rebuild (e.g. `package.json`). +#### Sync + Restart + +If `action` is set to `sync+restart`, Compose synchronizes your changes with the service containers and restarts it. + +`sync+restart` is ideal when config file changes, and you don't need to rebuild the image but just restart the main process of the service containers. +It will work well when you update a database configuration or your `nginx.conf` file for example + >**Tip** > > Optimize your `Dockerfile` for speedy