Added healthcheck that checks if network is still up
This commit is contained in:
10
Dockerfile
10
Dockerfile
@@ -34,11 +34,14 @@ RUN apt-get update \
|
||||
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
|
||||
&& groupmod -g 1000 users \
|
||||
&& useradd -u 911 -U -d /config -s /bin/false abc \
|
||||
&& usermod -G users abc
|
||||
&& usermod -G users abc \
|
||||
|
||||
ADD openvpn/ /etc/openvpn/
|
||||
ADD transmission/ /etc/transmission/
|
||||
ADD tinyproxy /opt/tinyproxy/
|
||||
ADD scripts /etc/scripts/
|
||||
|
||||
RUN chmod a+x /etc/scripts/healthcheck.sh
|
||||
|
||||
ENV OPENVPN_USERNAME=**None** \
|
||||
OPENVPN_PASSWORD=**None** \
|
||||
@@ -129,7 +132,10 @@ ENV OPENVPN_USERNAME=**None** \
|
||||
TRANSMISSION_WEB_HOME= \
|
||||
DROP_DEFAULT_ROUTE= \
|
||||
WEBPROXY_ENABLED=false \
|
||||
WEBPROXY_PORT=8888
|
||||
WEBPROXY_PORT=8888 \
|
||||
HEALTH_CHECK_HOST=google.com
|
||||
|
||||
HEALTHCHECK --interval=5m CMD /etc/scripts/healthcheck.sh
|
||||
|
||||
# Expose port and run
|
||||
EXPOSE 9091
|
||||
|
22
scripts/healthcheck.sh
Executable file
22
scripts/healthcheck.sh
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/bin/sh
|
||||
# Ping uses both exit codes 1 and 2. Exit code 2 cannot be used for docker health checks,
|
||||
# therefore we use this script to catch error code 2
|
||||
HOST=$HEALTH_CHECK_HOST
|
||||
|
||||
if [ -z "$HOST" ]
|
||||
then
|
||||
echo "Host not set! Set env 'HEATH_CHECK_HOST'. For now, using default google.com"
|
||||
HOST="google.com"
|
||||
fi
|
||||
|
||||
ping -c 1 $HOST
|
||||
STATUS=$?
|
||||
if [ $STATUS -ne 0 ]
|
||||
then
|
||||
echo "Network is down"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Network is up"
|
||||
exit 0
|
||||
|
Reference in New Issue
Block a user