Browse Source

fix(docker): wait for db:3306 to be available before starting pdns

Peter Thomassen 9 years ago
parent
commit
36c8fd53c9
2 changed files with 7 additions and 2 deletions
  1. 2 2
      Dockerfile
  2. 5 0
      entrypoint.sh

+ 2 - 2
Dockerfile

@@ -19,6 +19,6 @@ RUN apt-get update && apt-get install -y \
 
 
 COPY ./pdns-mysql.conf /etc/powerdns/pdns.d/pdns.local.gmysql.conf
 COPY ./pdns-mysql.conf /etc/powerdns/pdns.d/pdns.local.gmysql.conf
 COPY ./pdns.conf /etc/powerdns/pdns.conf
 COPY ./pdns.conf /etc/powerdns/pdns.conf
+COPY ./entrypoint.sh /root/
 
 
-CMD ["pdns_server","--daemon=no"]
-
+CMD ["/root/entrypoint.sh"]

+ 5 - 0
entrypoint.sh

@@ -0,0 +1,5 @@
+#!/bin/bash
+
+host=db; port=3306; n=120; i=0; while ! (echo > /dev/tcp/$host/$port) 2> /dev/null; do [[ $i -eq $n ]] && >&2 echo "$host:$port not up after $n seconds, exiting" && exit $port; echo "waiting for $host:$port to come up"; sleep 1; i=$((i+1)); done
+
+pdns_server --daemon=no