From 57609a595277bc8a2b8e1fbb5b21c3672942ff93 Mon Sep 17 00:00:00 2001 From: Bill Sideris Date: Sat, 18 Jun 2022 17:10:26 +0300 Subject: [PATCH 1/4] Add docker health check --- DockerHealthcheck.sh | 6 ++++++ Dockerfile | 2 ++ 2 files changed, 8 insertions(+) create mode 100755 DockerHealthcheck.sh diff --git a/DockerHealthcheck.sh b/DockerHealthcheck.sh new file mode 100755 index 000000000..6c0765768 --- /dev/null +++ b/DockerHealthcheck.sh @@ -0,0 +1,6 @@ +#!/bin/sh +if wget --spider -S "127.0.0.1:8080" 2>&1 | grep -w "302" ; then + exit 0 +else + exit 1 +fi diff --git a/Dockerfile b/Dockerfile index 1c94e8c6c..477dd963b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,3 +33,5 @@ RUN adduser -s /bin/false node; exit 0 # Start the application EXPOSE 8080 CMD [ "./start-docker.sh" ] + +HEALTHCHECK CMD sh DockerHealthcheck.sh From 0b0d1b59b9f732317a75015ac850248ee61a3e40 Mon Sep 17 00:00:00 2001 From: Bill Sideris Date: Sat, 18 Jun 2022 17:21:41 +0300 Subject: [PATCH 2/4] update it to check for login 200 --- DockerHealthcheck.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DockerHealthcheck.sh b/DockerHealthcheck.sh index 6c0765768..0dd14d5b6 100755 --- a/DockerHealthcheck.sh +++ b/DockerHealthcheck.sh @@ -1,5 +1,5 @@ #!/bin/sh -if wget --spider -S "127.0.0.1:8080" 2>&1 | grep -w "302" ; then +if wget --spider -S "127.0.0.1:8080/login" 2>&1 | grep -w "200" ; then exit 0 else exit 1 From 8bb8ab96f19b214148e4b44e0b202eb21a4b4c90 Mon Sep 17 00:00:00 2001 From: Bill Sideris Date: Sun, 19 Jun 2022 12:23:00 +0300 Subject: [PATCH 3/4] a bit better --- DockerHealthcheck.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DockerHealthcheck.sh b/DockerHealthcheck.sh index 0dd14d5b6..7459e6dbc 100755 --- a/DockerHealthcheck.sh +++ b/DockerHealthcheck.sh @@ -1,5 +1,5 @@ #!/bin/sh -if wget --spider -S "127.0.0.1:8080/login" 2>&1 | grep -w "200" ; then +if wget --spider -S "127.0.0.1:8080/login" 2>&1 | grep -w "HTTP/1.1 200 OK" ; then exit 0 else exit 1 From 8ac776f305ddfd8e1a4d53e7d3742345cbffc151 Mon Sep 17 00:00:00 2001 From: Bill Sideris Date: Sun, 19 Jun 2022 12:39:20 +0300 Subject: [PATCH 4/4] Slowly making it an oneliner, added line check --- DockerHealthcheck.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DockerHealthcheck.sh b/DockerHealthcheck.sh index 7459e6dbc..e0e9b6cda 100755 --- a/DockerHealthcheck.sh +++ b/DockerHealthcheck.sh @@ -1,5 +1,5 @@ #!/bin/sh -if wget --spider -S "127.0.0.1:8080/login" 2>&1 | grep -w "HTTP/1.1 200 OK" ; then +if wget --spider -S "127.0.0.1:8080/login" 2>&1 | awk 'NR==2' | grep -w "HTTP/1.1 200 OK" ; then exit 0 else exit 1