diff --git a/.dockerignore b/.dockerignore index 60b7a312..f3f249a3 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,3 @@ * +!.docker.json !filebrowser \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 98700278..8cbc7a5b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,10 @@ FROM alpine:latest -RUN apk --update add ca-certificates -RUN apk --update add mailcap +RUN apk --update add ca-certificates \ + mailcap \ + curl + +HEALTHCHECK --start-period=2s --interval=5s --timeout=3s \ + CMD curl -f http://localhost/health || exit 1 VOLUME /srv EXPOSE 80 diff --git a/http/http.go b/http/http.go index 80c7e92c..6afda6fa 100644 --- a/http/http.go +++ b/http/http.go @@ -36,6 +36,7 @@ func NewHandler( return handle(fn, prefix, store, server) } + r.HandleFunc("/health", healthHandler) r.PathPrefix("/static").Handler(static) r.NotFoundHandler = index diff --git a/http/public.go b/http/public.go index 8dc400d3..26bfffb8 100644 --- a/http/public.go +++ b/http/public.go @@ -136,3 +136,8 @@ func authenticateShareRequest(r *http.Request, l *share.Link) (int, error) { return 0, nil } + +func healthHandler(w http.ResponseWriter, _ *http.Request) { + w.WriteHeader(http.StatusOK) + _, _ = w.Write([]byte(`{"status":"OK"}`)) +}