From 6bb5443555e4b667c87465d57e4e4d34d7cca027 Mon Sep 17 00:00:00 2001 From: Allie Sadler <102604716+aevesdocker@users.noreply.github.com> Date: Thu, 4 Jul 2024 10:57:00 +0100 Subject: [PATCH] ENGDOCS-2144 (#20314) * ENGDOCS-2144 * edit --- content/compose/file-watch.md | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/content/compose/file-watch.md b/content/compose/file-watch.md index 3d5c35a6ca..58ed376e5e 100644 --- a/content/compose/file-watch.md +++ b/content/compose/file-watch.md @@ -110,7 +110,7 @@ For `path: ./app/html` and a change to `./app/html/index.html`: * `target: /app/static` -> `/app/static/index.html` * `target: /assets` -> `/assets/index.html` -## Example +## Example 1 This minimal example targets a Node.js application with the following structure: ```text @@ -153,6 +153,34 @@ rebuilds the image and recreates the `web` service container. This pattern can be followed for many languages and frameworks, such as Python with Flask: Python source files can be synced while a change to `requirements.txt` should trigger a rebuild. +## Example 2 + +Adapting the previous example to demonstrate `sync+restart`: + +```yaml +services: + web: + build: . + command: npm start + develop: + watch: + - action: sync + path: ./web + target: /app/web + ignore: + - node_modules/ + - action: sync+restart + path: ./proxy/nginx.conf + target: /etc/nginx/conf.d/default.conf + + backend: + build: + context: backend + target: builder +``` + +This setup demonstrates how to use the `sync+restart` action in Docker Compose to efficiently develop and test a Node.js application with a frontend web server and backend service. The configuration ensures that changes to the application code and configuration files are quickly synchronized and applied, with the `web` service restarting as needed to reflect the changes. + ## Use `watch` {{< include "compose/configure-watch.md" >}}