build: add healthcheck to docker image (!109)
* Update docker image to include a healthcheck instruction using a custom script * Replace docker base image with alpine https://gitlab.com/hectorjsmith/fail2ban-prometheus-exporter/-/merge_requests/109
This commit is contained in:
parent
a4c48ba46f
commit
9738a20a82
2 changed files with 14 additions and 1 deletions
|
@ -1,4 +1,4 @@
|
||||||
FROM debian:buster-slim
|
FROM alpine
|
||||||
|
|
||||||
# Create main app folder to run from
|
# Create main app folder to run from
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
@ -6,5 +6,10 @@ WORKDIR /app
|
||||||
# Copy compiled binary to release image
|
# Copy compiled binary to release image
|
||||||
# (must build the binary before running docker build)
|
# (must build the binary before running docker build)
|
||||||
COPY fail2ban_exporter /app/fail2ban_exporter
|
COPY fail2ban_exporter /app/fail2ban_exporter
|
||||||
|
COPY health /app/health
|
||||||
|
|
||||||
|
# Setup a healthcheck
|
||||||
|
RUN apk add curl
|
||||||
|
HEALTHCHECK --interval=10s --timeout=4s CMD /app/health
|
||||||
|
|
||||||
ENTRYPOINT ["/app/fail2ban_exporter"]
|
ENTRYPOINT ["/app/fail2ban_exporter"]
|
||||||
|
|
8
health
Executable file
8
health
Executable file
|
@ -0,0 +1,8 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
port=9191
|
||||||
|
if [ ! -z $F2B_WEB_LISTEN_ADDRESS ]; then
|
||||||
|
port=`echo $F2B_WEB_LISTEN_ADDRESS | cut -d ":" -f 2 -`
|
||||||
|
fi
|
||||||
|
|
||||||
|
curl --fail localhost:$port/metrics || exit 1
|
Loading…
Reference in a new issue