Add proper health check

This commit is contained in:
Ben Sarmiento
2023-11-22 08:59:08 +01:00
parent 074b2b78e5
commit eee83dacf7
2 changed files with 10 additions and 6 deletions

View File

@@ -20,10 +20,8 @@ COPY --from=builder /app/zurg .
# RUN apk add --no-cache upx
# RUN upx --brute zurg
# Create a health check script that extracts the port from the config file
RUN echo $'#!/bin/sh\n\
port=$(yaml read /app/config.yml port)\n\
nc -z localhost $port || exit 1' > /app/healthcheck.sh && \
chmod +x /app/healthcheck.sh
COPY ./healthcheck.sh /app/healthcheck.sh
RUN chmod +x /app/healthcheck.sh
# Final stage
FROM alpine:3
@@ -37,8 +35,7 @@ COPY --from=obfuscator /app/healthcheck.sh .
COPY config.example.yml /app/config.yml
# Install runtime dependencies and configure FUSE
RUN apk add --no-cache fuse3 netcat-openbsd yaml-cpp curl \
&& echo 'user_allow_other' >> /etc/fuse.conf
RUN apk add curl
HEALTHCHECK --interval=60s --timeout=60s --start-period=10s --retries=10 CMD /app/healthcheck.sh

7
healthcheck.sh Normal file
View File

@@ -0,0 +1,7 @@
#!/bin/sh
response=$(curl -o /dev/null -s -w "%{http_code}" http://localhost:9999)
if [ "$response" -eq 200 ]; then
exit 0
else
exit 1
fi