From eb7909219ff654f14de64b7437970e937e4af156 Mon Sep 17 00:00:00 2001 From: OpenClaw Date: Fri, 6 Mar 2026 22:07:51 +0000 Subject: [PATCH] fix(#10): Add Docker HEALTHCHECK on /health endpoint and document healthy/unhealthy criteria --- Dockerfile.test | 2 ++ docs/healthcheck.md | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 docs/healthcheck.md diff --git a/Dockerfile.test b/Dockerfile.test index 4977216..c9b6b85 100644 --- a/Dockerfile.test +++ b/Dockerfile.test @@ -7,4 +7,6 @@ RUN npm ci COPY backend/ ./ +HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 CMD curl -f http://localhost:3000/health || exit 1 + CMD ["npm", "test"] diff --git a/docs/healthcheck.md b/docs/healthcheck.md new file mode 100644 index 0000000..ddec285 --- /dev/null +++ b/docs/healthcheck.md @@ -0,0 +1,35 @@ +# Healthcheck + +## Endpoint + +The application exposes a `/health` endpoint at the root level which returns a JSON response indicating the health status of the application. + +### Example Response + +```json +{ + "status": "ok" +} +``` + +## Docker HEALTHCHECK + +The Docker image includes a `HEALTHCHECK` instruction that verifies the application's health by making an HTTP request to the `/health` endpoint. + +### Healthcheck Configuration + +- **Interval**: 30 seconds +- **Timeout**: 10 seconds +- **Start Period**: 5 seconds +- **Retries**: 3 attempts + +### Healthy Status + +The container is considered healthy if the `/health` endpoint returns a successful HTTP response (status code 2xx). + +### Unhealthy Status + +The container is considered unhealthy if: + +1. The `/health` endpoint is unreachable. +2. The `/health` endpoint returns an error status code (4xx or 5xx). \ No newline at end of file