ENGDOCS-2144 (#20314)

* ENGDOCS-2144

* edit
This commit is contained in:
Allie Sadler 2024-07-04 10:57:00 +01:00 committed by GitHub
parent 9e80b3016e
commit 6bb5443555
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 29 additions and 1 deletions

View File

@ -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" >}}