Skip to content

Commit 6bb5443

Browse files
authored
ENGDOCS-2144 (docker#20314)
* ENGDOCS-2144 * edit
1 parent 9e80b30 commit 6bb5443

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

content/compose/file-watch.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ For `path: ./app/html` and a change to `./app/html/index.html`:
110110
* `target: /app/static` -> `/app/static/index.html`
111111
* `target: /assets` -> `/assets/index.html`
112112

113-
## Example
113+
## Example 1
114114

115115
This minimal example targets a Node.js application with the following structure:
116116
```text
@@ -153,6 +153,34 @@ rebuilds the image and recreates the `web` service container.
153153

154154
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.
155155

156+
## Example 2
157+
158+
Adapting the previous example to demonstrate `sync+restart`:
159+
160+
```yaml
161+
services:
162+
web:
163+
build: .
164+
command: npm start
165+
develop:
166+
watch:
167+
- action: sync
168+
path: ./web
169+
target: /app/web
170+
ignore:
171+
- node_modules/
172+
- action: sync+restart
173+
path: ./proxy/nginx.conf
174+
target: /etc/nginx/conf.d/default.conf
175+
176+
backend:
177+
build:
178+
context: backend
179+
target: builder
180+
```
181+
182+
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.
183+
156184
## Use `watch`
157185

158186
{{< include "compose/configure-watch.md" >}}

0 commit comments

Comments
 (0)