Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Add healthcheck for default localhost 8008 port on /health endpoint. #8147

Merged
merged 5 commits into from
Aug 24, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/8147.docker
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added curl for healthcheck support and readme updates for the change. Contributed by @maquis196.
4 changes: 4 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ RUN pip install --prefix="/install" --no-warn-script-location \
FROM docker.io/python:${PYTHON_VERSION}-slim

RUN apt-get update && apt-get install -y \
curl \
libpq5 \
xmlsec1 \
gosu \
Expand All @@ -69,3 +70,6 @@ VOLUME ["/data"]
EXPOSE 8008/tcp 8009/tcp 8448/tcp

ENTRYPOINT ["/start.py"]

HEALTHCHECK --interval=1m --timeout=5s \
CMD curl -fSs http://localhost:8008/health || exit 1
28 changes: 28 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,31 @@ docker build -t matrixdotorg/synapse -f docker/Dockerfile .

You can choose to build a different docker image by changing the value of the `-f` flag to
point to another Dockerfile.

## Disabling the healthcheck

If you are using a non-standard port or tls inside docker you can disable the healthcheck
whilst running the above `docker run` commands.

```
--no-healthcheck
```
## Setting custom healthcheck on docker run

If you wish to point the healthcheck at a different port with docker command, add the following

```
--health-cmd 'curl -fSs http://localhost:1234/health'
```

## Setting the healthcheck in docker-compose file

You can add the following to set a custom healthcheck in a docker compose file. You'll need version >2.1 for this to work.
babolivier marked this conversation as resolved.
Show resolved Hide resolved

```
healthcheck:
test: ["CMD", "curl", "-fSs", "http://localhost:8008/health"]
interval: 1m
timeout: 10s
retries: 3
```