From 2eff8734dfb489c1cc773818335585f8fbf45956 Mon Sep 17 00:00:00 2001 From: Chris Nesbitt-Smith Date: Wed, 26 Sep 2018 14:48:13 +0100 Subject: [PATCH 1/2] add a docker healthcheck --- Dockerfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Dockerfile b/Dockerfile index ddda30b..07dbf78 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ FROM node:10.1.0-alpine +RUN apk add --no-cache curl WORKDIR /app @@ -11,3 +12,6 @@ COPY . /app ENV NODE_ENV production ENTRYPOINT ["node", "-r", "esm", "./bin/server"] + +HEALTHCHECK --start-period=30s \ + CMD curl -s localhost:$(netstat -nltWep | grep 1/node | awk '{ print $4 }'| cut -d ":" -f 2) || exit 1 \ No newline at end of file -- 2.54.0 From 6bc65558944aa0554a3e5f102abaa723b5da8d8a Mon Sep 17 00:00:00 2001 From: Chris Nesbitt-Smith Date: Wed, 26 Sep 2018 14:55:42 +0100 Subject: [PATCH 2/2] use the /api/status rather than / for healthcheck --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 07dbf78..a82fb7f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,4 +14,4 @@ ENV NODE_ENV production ENTRYPOINT ["node", "-r", "esm", "./bin/server"] HEALTHCHECK --start-period=30s \ - CMD curl -s localhost:$(netstat -nltWep | grep 1/node | awk '{ print $4 }'| cut -d ":" -f 2) || exit 1 \ No newline at end of file + CMD curl -s localhost:$(netstat -nltWep | grep 1/node | awk '{ print $4 }'| cut -d ":" -f 2)/api/status || exit 1 \ No newline at end of file -- 2.54.0