From ed2cdaf71d050def667d421c7c045cd03c8d2bbf Mon Sep 17 00:00:00 2001 From: m1k1o Date: Fri, 19 Mar 2021 14:42:54 +0100 Subject: [PATCH] add HEALTHCHECK. --- .m1k1o/base/Dockerfile | 3 +++ README.md | 1 + server/internal/http/http.go | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/.m1k1o/base/Dockerfile b/.m1k1o/base/Dockerfile index 457232cc..dc0a49db 100644 --- a/.m1k1o/base/Dockerfile +++ b/.m1k1o/base/Dockerfile @@ -117,6 +117,9 @@ ENV NEKO_BIND=:8080 COPY --from=server /src/bin/neko /usr/bin/neko COPY --from=client /src/dist/ /var/www +HEALTHCHECK --interval=10s --timeout=5s --retries=8 \ + CMD wget -O - http://localhost:${NEKO_BIND#*:}/health || exit 1 + # # run neko CMD ["/usr/bin/supervisord", "-c", "/etc/neko/supervisord.conf"] diff --git a/README.md b/README.md index bc5bc20f..82d1d4db 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,7 @@ For n.eko room management software visit https://github.com/m1k1o/neko-rooms. - Fixed small lags in video and improved video UX (by @mbattista). - Added `m1k1o/neko:vncviewer` tag, use `NEKO_VNC_URL` to specify VNC target and use n.eko as a bridge. - Abiltiy to include neko as a component in another Vue.Js project (by @gbrian). +- Added HEALTHCHECK to Dockerfile. # Getting started & FAQ diff --git a/server/internal/http/http.go b/server/internal/http/http.go index 32c1c10f..434c0f85 100644 --- a/server/internal/http/http.go +++ b/server/internal/http/http.go @@ -34,6 +34,10 @@ func New(conf *config.Server, webSocketHandler types.WebSocketHandler) *Server { webSocketHandler.Upgrade(w, r) }) + router.Get("/health", func(w http.ResponseWriter, r *http.Request) { + w.Write([]byte("true")) + }) + fs := http.FileServer(http.Dir(conf.Static)) router.Get("/*", func(w http.ResponseWriter, r *http.Request) { if _, err := os.Stat(conf.Static + r.URL.Path); !os.IsNotExist(err) {