merge: add-healthcheck-to-docker-image

* Merge branch 'add-healthcheck-to-docker-image' into 'main'
* See merge request hectorjsmith/fail2ban-prometheus-exporter!109
* Merged by: Hector <hector@hjs.dev>
This commit is contained in:
Hector 2023-09-07 21:16:20 +00:00
commit f92318e864
No known key found for this signature in database
2 changed files with 14 additions and 1 deletions

View file

@ -1,4 +1,4 @@
FROM debian:buster-slim
FROM alpine
# Create main app folder to run from
WORKDIR /app
@ -6,5 +6,10 @@ WORKDIR /app
# Copy compiled binary to release image
# (must build the binary before running docker build)
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"]

8
health Executable file
View 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