From 4af563ce8938ed59b979fafd2125dc64fa634d4e Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sat, 19 Sep 2020 11:43:22 +0200 Subject: [PATCH] proxy: implement simple healthcheck --- proxy/Dockerfile | 6 +++++- proxy/pkg/server/api.go | 1 - proxy/pkg/server/server.go | 4 ++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/proxy/Dockerfile b/proxy/Dockerfile index 91b4eb714..2783b1ac3 100644 --- a/proxy/Dockerfile +++ b/proxy/Dockerfile @@ -7,6 +7,10 @@ COPY . . RUN go build -o /work/proxy . # Copy binary to alpine -FROM gcr.io/distroless/base-debian10 +FROM gcr.io/distroless/base-debian10:debug + COPY --from=builder /work/proxy / + +HEALTHCHECK CMD [ "wget", "spider", "http://localhost:4180/pbprox/ping" ] + ENTRYPOINT ["/proxy"] diff --git a/proxy/pkg/server/api.go b/proxy/pkg/server/api.go index fd8251f76..becae3db5 100644 --- a/proxy/pkg/server/api.go +++ b/proxy/pkg/server/api.go @@ -47,7 +47,6 @@ func getCommonOptions() *options.Options { commonOpts.EmailDomains = []string{"*"} commonOpts.ProviderType = "oidc" commonOpts.ProxyPrefix = "/pbprox" - commonOpts.PingPath = "/pbprox/ping" commonOpts.SkipProviderButton = true commonOpts.Logging.SilencePing = true commonOpts.SetXAuthRequest = true diff --git a/proxy/pkg/server/server.go b/proxy/pkg/server/server.go index 9d71dbda3..8f22c34aa 100644 --- a/proxy/pkg/server/server.go +++ b/proxy/pkg/server/server.go @@ -82,6 +82,10 @@ func (s *Server) ServeHTTPS() { } func (s *Server) handler(w http.ResponseWriter, r *http.Request) { + if r.URL.Path == "/pbprox/ping" { + w.WriteHeader(204) + return + } handler, ok := s.Handlers[r.Host] if !ok { // If we only have one handler, host name switching doesn't matter