diff --git a/Dockerfile b/Dockerfile index c51ce17..7de1999 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,9 @@ -FROM basessh +FROM ubuntu:trusty MAINTAINER Dave P -# Bind setup script -COPY regen-bind-key /start.d/regen-bind-key - -# Supervisor script -COPY bind.conf /etc/supervisor/conf.d/bind.conf - # Install bind and dns utils RUN apt-get update ; \ - apt-get install -y bind9 dnsutils ; \ + apt-get install -y supervisor bind9 dnsutils ; \ rm /etc/bind/rndc.key ; \ chmod +x /start.d/regen-bind-key ; \ mkdir /var/run/named ; \ @@ -18,8 +12,17 @@ RUN apt-get update ; \ touch /var/log/named.log ; \ chgrp bind /var/log/named.log ; \ chmod 775 /var/log/named.log ; \ - sed -i -e's/include "\/etc\/bind\/named.conf.options";/logging{\n\tchannel simple_log {\n\t\tfile "\/var\/log\/named.log" versions 3 size 5m;\n\t\tseverity info;\n\t\tprint-time yes;\n\t\tprint-severity yes;\n\t\tprint-category yes;\n\t};\n\tcategory default{\n\t\tsimple_log;\n\t};\n};\ninclude "\/etc\/bind\/named.conf.options";/' /etc/bind/named.conf - # edit named.conf to use the above log file + sed -i -e's/include "\/etc\/bind\/named.conf.options";/logging{\n\tchannel simple_log {\n\t\tfile "\/var\/log\/named.log" versions 3 size 5m;\n\t\tseverity info;\n\t\tprint-time yes;\n\t\tprint-severity yes;\n\t\tprint-category yes;\n\t};\n\tcategory default{\n\t\tsimple_log;\n\t};\n};\ninclude "\/etc\/bind\/named.conf.options";/' /etc/bind/named.conf ; \ + mkdir /start.d + +# Supervisor script +ADD bind.conf /etc/supervisor/conf.d/bind.conf +ADD supervisor.conf /etc/supervisor/conf.d/supervisor.conf + +# Bind setup script +ADD regen-bind-key /start.d/regen-bind-key + +ADD start /start # DNS port EXPOSE 53/udp diff --git a/regen-bind-key b/regen-bind-key old mode 100644 new mode 100755 index 708f106..dd95ca0 --- a/regen-bind-key +++ b/regen-bind-key @@ -1,8 +1,7 @@ #!/bin/bash # reconfigure bind - regenerates secret keys -dpkg-reconfigure bind9 +rndc-confgen -a -r /dev/urandom # Only run once rm /start.d/regen-bind-key - diff --git a/start b/start new file mode 100755 index 0000000..465c607 --- /dev/null +++ b/start @@ -0,0 +1,10 @@ +#!/bin/bash + +# run everything in start.d +find /start.d -type f -executable -exec {} \; + +# Cleanly kill supervisor when container is stopped +trap 'kill $(jobs -p)' EXIT + +# start services +supervisord diff --git a/supervisor.conf b/supervisor.conf new file mode 100644 index 0000000..54296b8 --- /dev/null +++ b/supervisor.conf @@ -0,0 +1,2 @@ +[supervisord] +nodaemon=true