diff --git a/Dockerfile b/Dockerfile index 1587fd7..0a244e2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,6 +28,7 @@ LABEL org.opencontainers.image.title="zerotier" \ org.opencontainers.image.source="https://github.com/zyclonite/zerotier-docker" COPY --from=builder /src/zerotier-one /scripts/entrypoint.sh /usr/sbin/ +COPY --from=builder --chmod=755 /scripts/healthcheck.sh /usr/sbin/ RUN apk add --no-cache --purge --clean-protected libc6-compat libstdc++ \ && mkdir -p /var/lib/zerotier-one \ @@ -37,6 +38,9 @@ RUN apk add --no-cache --purge --clean-protected libc6-compat libstdc++ \ EXPOSE 9993/udp +HEALTHCHECK --interval=60s --timeout=8s \ + CMD /bin/sh /usr/sbin/healthcheck.sh + ENTRYPOINT ["entrypoint.sh"] CMD ["-U"] diff --git a/scripts/healthcheck.sh b/scripts/healthcheck.sh new file mode 100644 index 0000000..87ec80e --- /dev/null +++ b/scripts/healthcheck.sh @@ -0,0 +1,14 @@ +## Adding of HealthCheck has been sponsored by PMGA Tech LLP. +#!/bin/sh + +#Exit Codes +# 0= Success +# Failure + +status=$(zerotier-cli status | awk '{print $5}') + +if [[ "$status" = "ONLINE" ]] ; then + exit 0 +else + exit 1 +fi