Merge pull request #1596 from erikh/docker-image-fixes

Fix dockerfile & entrypoint:
This commit is contained in:
Erik Hollensbe 2022-03-24 10:53:52 -07:00 committed by GitHub
commit 76e30cf165
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 11 deletions

View File

@ -11,6 +11,8 @@ RUN curl -sSL -o zerotier-one.deb "${PACKAGE_BASEURL}/zerotier-one_${VERSION}_${
FROM debian:buster FROM debian:buster
RUN apt-get update -qq && apt-get install openssl libssl1.1 -y
COPY --from=stage zerotier-one.deb . COPY --from=stage zerotier-one.deb .
RUN dpkg -i zerotier-one.deb && rm -f zerotier-one.deb RUN dpkg -i zerotier-one.deb && rm -f zerotier-one.deb
@ -20,5 +22,7 @@ RUN rm -rf /var/lib/zerotier-one
COPY entrypoint.sh.release /entrypoint.sh COPY entrypoint.sh.release /entrypoint.sh
RUN chmod 755 /entrypoint.sh RUN chmod 755 /entrypoint.sh
HEALTHCHECK --interval=1s CMD bash /healthcheck.sh
CMD [] CMD []
ENTRYPOINT ["/entrypoint.sh"] ENTRYPOINT ["/entrypoint.sh"]

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
grepzt() { grepzt() {
[ ! -n "$(cat /var/lib/zerotier-one/zerotier-one.pid)" -a -d "/proc/$(cat /var/lib/zerotier-one/zerotier-one.pid)" ] [ -f /var/lib/zerotier-one/zerotier-one.pid -a -n "$(cat /var/lib/zerotier-one/zerotier-one.pid)" -a -d "/proc/$(cat /var/lib/zerotier-one/zerotier-one.pid)" ]
return $? return $?
} }
@ -40,26 +40,45 @@ killzerotier() {
trap killzerotier INT TERM trap killzerotier INT TERM
echo "Configuring networks to join"
mkdir -p /var/lib/zerotier-one/networks.d
echo "joining networks: $@"
for i in "$@"
do
echo "Configuring join for $i"
touch "/var/lib/zerotier-one/networks.d/${i}.conf"
done
echo "starting zerotier" echo "starting zerotier"
nohup /usr/sbin/zerotier-one & nohup /usr/sbin/zerotier-one &
while ! grepzt while ! grepzt
do do
echo "zerotier hasn't started, waiting a second" echo "zerotier hasn't started, waiting a second"
if [ -f nohup.out ]
then
tail -n 10 nohup.out
fi
sleep 1 sleep 1
done done
echo "joining networks: $@" echo "Writing healthcheck for networks: $@"
for i in "$@" cat >/healthcheck.sh <<EOF
#!/bin/bash
for i in $@
do do
echo "joining $i" [ "\$(zerotier-cli get \$i status)" = "OK" ] || exit 1
while ! zerotier-cli join "$i"
do
echo "joining $i failed; trying again in 1s"
sleep 1
done
done done
EOF
sleep infinity chmod +x /healthcheck.sh
echo "Sleeping infinitely"
while true
do
sleep 1
done