From 27395d5f5075daba711a2d193d8dfec408aa2c2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6ran=20Tesse?= Date: Fri, 9 Nov 2018 15:30:48 +0100 Subject: [PATCH 1/3] added curl-based health check --- Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 64b2c61..d994d0b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM ruby:alpine -RUN apk update && apk upgrade && apk add perl perl-net-ssleay make g++ openssl +RUN apk update && apk upgrade && apk add perl perl-net-ssleay make g++ openssl curl WORKDIR /sectools/ @@ -8,6 +8,8 @@ RUN wget https://github.com/sullo/nikto/archive/master.tar.gz -P /sectools && \ tar zxvf /sectools/master.tar.gz -C /sectools && \ rm /sectools/master.tar.gz +HEALTHCHECK --interval=5s --timeout=5s --start-period=30s --retries=3 CMD curl --fail http://localhost:8080/status || exit 1 + COPY Gemfile src/ RUN bundle install --gemfile=/sectools/src/Gemfile From 8999852bef961e6f7069e185b63912ba737009ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6ran=20Tesse?= Date: Fri, 9 Nov 2018 15:31:44 +0100 Subject: [PATCH 2/3] =?UTF-8?q?unhealthy=20state=20now=20depends=20on=20th?= =?UTF-8?q?e=20scanner=E2=80=99s=20availability=20rather=20than=20the=20en?= =?UTF-8?q?gine=E2=80=99s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.rb b/src/main.rb index e6d4523..42db01e 100644 --- a/src/main.rb +++ b/src/main.rb @@ -15,7 +15,7 @@ get '/status' do status 500 - if (healthcheck(client.last_connect) == "UP") + if (scanner_test == "SUCCESSFUL") status 200 end @@ -46,7 +46,7 @@ end def healthcheck(connection) - if (connection != "ERROR" && scanner_test == "SUCCESSFULL") + if (connection != "ERROR" && scanner_test == "SUCCESSFUL") return "UP" end return "DOWN" @@ -55,7 +55,7 @@ def healthcheck(connection) def scanner_test system('perl /sectools/nikto-master/program/nikto.pl -Version > /dev/null') if $? == 0 - return "SUCCESSFULL" + return "SUCCESSFUL" else return "FAILED" end From 55549209610051f9089a2eb4e3b268b2e7a338c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6ran=20Tesse?= Date: Mon, 12 Nov 2018 13:05:26 +0100 Subject: [PATCH 3/3] more sane timings for healthcheck --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index d994d0b..4675d39 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ RUN wget https://github.com/sullo/nikto/archive/master.tar.gz -P /sectools && \ tar zxvf /sectools/master.tar.gz -C /sectools && \ rm /sectools/master.tar.gz -HEALTHCHECK --interval=5s --timeout=5s --start-period=30s --retries=3 CMD curl --fail http://localhost:8080/status || exit 1 +HEALTHCHECK --interval=30s --timeout=5s --start-period=120s --retries=3 CMD curl --fail http://localhost:8080/status || exit 1 COPY Gemfile src/