From 1fddeda86471e4f5c0cf37598e8f324c434a3d33 Mon Sep 17 00:00:00 2001 From: Steve HOLWEG Date: Mon, 11 Dec 2017 14:18:10 +0100 Subject: [PATCH] Pdns recursor (#6) * Adding pdns recursor * Adding pdns recursor with fedora * pdns resolver version correction * Update readme for pdns-recursor --- README.md | 27 ++++++++++++++++++++++++++- pdns-recursor/Dockerfile | 22 ++++++++++++++++++++++ pdns-recursor/Dockerfile.alpine | 22 ++++++++++++++++++++++ pdns-recursor/docker-cmd.sh | 14 ++++++++++++++ pdns-recursor/recursor.conf.tpl | 2 ++ 5 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 pdns-recursor/Dockerfile create mode 100644 pdns-recursor/Dockerfile.alpine create mode 100755 pdns-recursor/docker-cmd.sh create mode 100644 pdns-recursor/recursor.conf.tpl diff --git a/README.md b/README.md index 1ded609..e961746 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # PowerDNS Docker Images -This repository contains four Docker images - pdns-mysql, pdns-admin-static, pdns-admin-uwsgi and deprecated pdns-admin. Image **pdns-mysql** contains completely configurable [PowerDNS 4.x server](https://www.powerdns.com/) with mysql backend (without mysql server). Images **pdns-admin-static** and **pdns-admin-uwsgi** contains fronted (nginx) and backend (uWSGI) for [PowerDNS Admin](https://git.0x97.io/0x97/powerdns-admin) web app, written in Flask, for managing PowerDNS servers. Pdns-admin is also completely configurable. Deprecated **pdns-admin** contains PowerDNS Admin in a single image where both nginx and uWSGI processes are managed by systemd. This image won't be updated anymore. +This repository contains five Docker images - pdns-mysql, pdns-admin-static, pdns-admin-uwsgi, pdns-recursor and deprecated pdns-admin. Image **pdns-mysql** contains completely configurable [PowerDNS 4.x server](https://www.powerdns.com/) with mysql backend (without mysql server). Image **pdns-recursor** contains completely configurable [PowerDNS 4.x recursor](https://www.powerdns.com/). Images **pdns-admin-static** and **pdns-admin-uwsgi** contains fronted (nginx) and backend (uWSGI) for [PowerDNS Admin](https://git.0x97.io/0x97/powerdns-admin) web app, written in Flask, for managing PowerDNS servers. Pdns-admin is also completely configurable. Deprecated **pdns-admin** contains PowerDNS Admin in a single image where both nginx and uWSGI processes are managed by systemd. This image won't be updated anymore. All images are available on Docker Hub: @@ -146,6 +146,31 @@ docker run -d -p 8080:80 --name pdns-admin-static \ pschiffe/pdns-admin-static ``` +## pdns-recursor + +[![](https://images.microbadger.com/badges/image/pschiffe/pdns-recursor.svg)](http://microbadger.com/images/pschiffe/pdns-recursor "Get your own image badge on microbadger.com") + +https://hub.docker.com/r/pschiffe/pdns-recursor/ + +Docker image with [PowerDNS 4.x recursor](https://www.powerdns.com/). + +PowerDNS recursor is configurable via env vars. Every variable starting with `PDNS_` will be inserted into `/etc/pdns/recursor.conf` conf file in the following way: prefix `PDNS_` will be stripped and every `_` will be replaced with `-`. For example, from above mysql config, `PDNS_gmysql_host=mysql` will became `gmysql-host=mysql` in `/etc/pdns/recursor.conf` file. This way, you can configure PowerDNS recursor any way you need within a `docker run` command. + +You can find [here](https://doc.powerdns.com/md/recursor/settings/) all available settings. + +### Examples + +Recursor server with API enabled: +``` +docker run -d -p 53:53 -p 53:53/udp --name pdns-recursor \ + -e PDNS_api=yes \ + -e PDNS_api_key=secret \ + -e PDNS_webserver=yes \ + -e PDNS_webserver_address=0.0.0.0 \ + -e PDNS_webserver_password=secret2 \ + pschiffe/pdns-recursor +``` + ## pdns-admin - DEPRECATED [![](https://images.microbadger.com/badges/image/pschiffe/pdns-admin.svg)](http://microbadger.com/images/pschiffe/pdns-admin "Get your own image badge on microbadger.com") diff --git a/pdns-recursor/Dockerfile b/pdns-recursor/Dockerfile new file mode 100644 index 0000000..d33113f --- /dev/null +++ b/pdns-recursor/Dockerfile @@ -0,0 +1,22 @@ +FROM fedora:27 +MAINTAINER "Peter Schiffer" + +RUN sed -i '/tsflags=nodocs/d' /etc/dnf/dnf.conf \ + && dnf -y --setopt=install_weak_deps=False install \ + pdns-recursor \ + && dnf clean all + +RUN pip3 install envtpl \ + && rm -rf ~/.cache/* + +ENV VERSION=4.0.6 \ + PDNS_setuid=recursor \ + PDNS_setgid=recursor \ + PDNS_daemon=no + +EXPOSE 53 53/udp + +COPY recursor.conf.tpl / +COPY docker-cmd.sh / + +CMD [ "/docker-cmd.sh" ] diff --git a/pdns-recursor/Dockerfile.alpine b/pdns-recursor/Dockerfile.alpine new file mode 100644 index 0000000..083fefb --- /dev/null +++ b/pdns-recursor/Dockerfile.alpine @@ -0,0 +1,22 @@ +FROM alpine:3.7 +MAINTAINER "Peter Schiffer" + +RUN set -xe \ + && apk update --no-cache && apk upgrade --no-cache \ + && apk add --update --no-cache pdns-recursor python3 \ + && rm -rf /var/cache/apk/* + +RUN pip3 install envtpl \ + && rm -rf ~/.cache/* + +ENV VERSION=4.0.6 \ + PDNS_setuid=recursor \ + PDNS_setgid=recursor \ + PDNS_daemon=no + +EXPOSE 53 53/udp + +COPY recursor.conf.tpl / +COPY docker-cmd.sh / + +CMD [ "/docker-cmd.sh" ] diff --git a/pdns-recursor/docker-cmd.sh b/pdns-recursor/docker-cmd.sh new file mode 100755 index 0000000..2209349 --- /dev/null +++ b/pdns-recursor/docker-cmd.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +set -euo pipefail + +# Configure base vars +: "${PDNS_local_port:=53}" +: "${PDNS_local_address:=0.0.0.0}" + +export PDNS_local_port PDNS_local_address + +# Create config file from template +envtpl < /recursor.conf.tpl > /etc/pdns/recursor.conf + +exec /usr/sbin/pdns_recursor diff --git a/pdns-recursor/recursor.conf.tpl b/pdns-recursor/recursor.conf.tpl new file mode 100644 index 0000000..8330f43 --- /dev/null +++ b/pdns-recursor/recursor.conf.tpl @@ -0,0 +1,2 @@ +{% for key, value in environment('PDNS_') %}{{ key|replace('_', '-') }}={{ value }} +{% endfor %}