Add health check to the project

This commit is contained in:
stremovsky
2021-12-17 09:43:48 +02:00
parent 178ffa653d
commit 540bdf5022
2 changed files with 27 additions and 1 deletions

View File

@@ -41,7 +41,8 @@ RUN /bin/busybox mkdir -p /databunker/data && \
# Tell docker that all future commands should run as the appuser user
USER appuser
COPY --from=builder /go/bin/databunker /databunker/bin/databunker
COPY run.sh /databunker/bin/
COPY run.sh health-check.sh /databunker/bin/
EXPOSE 3000
HEALTHCHECK --interval=5s --timeout=3s --start-period=33s --retries=3 CMD /databunker/bin/health-check.sh
ENTRYPOINT ["/bin/sh", "/databunker/bin/run.sh"]
#CMD ["/bin/sh", "-x", "-c", "/go/bin/databunker -init"]

25
health-check.sh Executable file
View File

@@ -0,0 +1,25 @@
#!/bin/sh
# check if Databunker is using SSL port
if [ -n "$SSL_CERTIFICATE" ]; then
if [ -f "$SSL_CERTIFICATE" ]; then
/bin/busybox wget --tries=1 --spider --no-check-certificate -q https://localhost:3000/status || exit 1
exit 0
fi
fi
if [ -f "/databunker/certs/server.cer" ]; then
/bin/busybox wget --tries=1 --spider --no-check-certificate -q https://localhost:3000/status || exit 1
exit 0
fi
CERT_FILE=`/bin/busybox sed -n -e '/ssl_certificate:/ s/ .*ssl_certificate: "\(.*\)"/\1/p' /databunker/conf/databunker.yaml`
if [ -n "$CERT_FILE" ]; then
if [ -f "$CERT_FILE" ]; then
/bin/busybox wget --tries=1 --spider --no-check-certificate -q https://localhost:3000/status || exit 1
exit 0
fi
fi
# by default check http port
/bin/busybox wget --tries=1 --spider -q http://localhost:3000/status || exit 1