docs(docker): add healthcheck to docker-compose (#9742)

### Purpose

Syncthing had a healthcheck API for a while, and the example Dockerfile
for it has it in the form of:

HEALTHCHECK --interval=1m --timeout=10s \
CMD curl -fkLsS -m 2 127.0.0.1:8384/rest/noauth/health | grep -o
--color=never OK || exit 1

Let's add it to the docker-compose as well

### Testing

I use this docker-compose.yml file to deploy via ansible (using
community.docker.docker_compose_v2) to my machine with success, using
`wait: true` in ansible for it to use `docker compose up --wait`.

```yml
- name: Enable syncthing docker
  community.docker.docker_compose_v2:
    project_src: /srv/syncthing
    wait: true
    wait_timeout: 90
```
This commit is contained in:
maxice8 2024-09-29 11:53:13 -03:00 committed by GitHub
parent 605fd6d726
commit 429672e0b4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -49,6 +49,11 @@ services:
- 22000:22000/udp # QUIC file transfers - 22000:22000/udp # QUIC file transfers
- 21027:21027/udp # Receive local discovery broadcasts - 21027:21027/udp # Receive local discovery broadcasts
restart: unless-stopped restart: unless-stopped
healthcheck:
test: curl -fkLsS -m 2 127.0.0.1:8384/rest/noauth/health | grep -o --color=never OK || exit 1
interval: 1m
timeout: 10s
retries: 3
``` ```
## Discovery ## Discovery
@ -84,6 +89,11 @@ services:
- /wherever/st-sync:/var/syncthing - /wherever/st-sync:/var/syncthing
network_mode: host network_mode: host
restart: unless-stopped restart: unless-stopped
healthcheck:
test: curl -fkLsS -m 2 127.0.0.1:8384/rest/noauth/health | grep -o --color=never OK || exit 1
interval: 1m
timeout: 10s
retries: 3
``` ```
Be aware that syncthing alone is now in control of what interfaces and ports it Be aware that syncthing alone is now in control of what interfaces and ports it