Skip to content
This repository was archived by the owner on May 13, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 49 additions & 28 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,33 +1,54 @@
FROM alpine:3.9
MAINTAINER Christoph Wiechert <wio@psitrax.de>

ENV POWERDNS_VERSION=4.3.1 \
MYSQL_DEFAULT_AUTOCONF=true \
MYSQL_DEFAULT_HOST="mysql" \
MYSQL_DEFAULT_PORT="3306" \
MYSQL_DEFAULT_USER="root" \
MYSQL_DEFAULT_PASS="root" \
MYSQL_DEFAULT_DB="pdns"

RUN apk --update add bash libpq sqlite-libs libstdc++ libgcc mariadb-client mariadb-connector-c lua-dev curl-dev && \
apk add --virtual build-deps \
g++ make mariadb-dev postgresql-dev sqlite-dev curl boost-dev mariadb-connector-c-dev && \
curl -sSL https://downloads.powerdns.com/releases/pdns-$POWERDNS_VERSION.tar.bz2 | tar xj -C /tmp && \
cd /tmp/pdns-$POWERDNS_VERSION && \
./configure --prefix="" --exec-prefix=/usr --sysconfdir=/etc/pdns \
--with-modules="bind gmysql gpgsql gsqlite3" && \
make && make install-strip && cd / && \
mkdir -p /etc/pdns/conf.d && \
FROM alpine:3.9 as base

ENV REFRESHED_AT="2019-10-10" \
POWERDNS_VERSION="4.3.1" \
BUILD_DEPS="g++ make mariadb-dev postgresql-dev sqlite-dev curl boost-dev mariadb-connector-c-dev" \
RUN_DEPS="bash libpq sqlite-libs libstdc++ libgcc mariadb-client postgresql-client sqlite mariadb-connector-c lua-dev curl-dev boost-program_options" \
POWERDNS_MODULES="bind gmysql gpgsql gsqlite3"

FROM base AS build

RUN apk --update add $BUILD_DEPS $RUN_DEPS
RUN curl -sSL https://downloads.powerdns.com/releases/pdns-$POWERDNS_VERSION.tar.bz2 | tar xj -C /tmp/
WORKDIR /tmp/pdns-$POWERDNS_VERSION
RUN ./configure --prefix="" --exec-prefix=/usr --sysconfdir=/etc/pdns --with-modules="$POWERDNS_MODULES"
RUN make
RUN DESTDIR="/pdnsbuild" make install-strip
RUN mkdir -p /pdnsbuild/etc/pdns/conf.d /pdnsbuild/etc/pdns/sql
RUN cp modules/gmysqlbackend/*.sql modules/gpgsqlbackend/*.sql modules/gsqlite3backend/*.sql /pdnsbuild/etc/pdns/sql/

FROM base

COPY --from=build /pdnsbuild /
RUN apk add $RUN_DEPS && \
addgroup -S pdns 2>/dev/null && \
adduser -S -D -H -h /var/empty -s /bin/false -G pdns -g pdns pdns 2>/dev/null && \
cp /usr/lib/libboost_program_options-mt.so* /tmp && \
apk del --purge build-deps && \
mv /tmp/lib* /usr/lib/ && \
rm -rf /tmp/pdns-$POWERDNS_VERSION /var/cache/apk/*
rm /var/cache/apk/*

ADD schema.sql pdns.conf /etc/pdns/
ADD entrypoint.sh /
LABEL \
MAINTAINER="Christoph Wiechert <wio@psitrax.de>" \
CONTRIBUTORS="Mathias Kaufmann <me@stei.gr>, Cloudesire <cloduesire-dev@eng.it>"

EXPOSE 53/tcp 53/udp
ENV AUTOCONF=mysql \
AUTO_SCHEMA_MIGRATION="no" \
MYSQL_HOST="mysql" \
MYSQL_PORT="3306" \
MYSQL_USER="root" \
MYSQL_PASS="root" \
MYSQL_DB="pdns" \
MYSQL_DNSSEC="no" \
MYSQL_VERSION="4.3.0" \
PGSQL_HOST="postgres" \
PGSQL_PORT="5432" \
PGSQL_USER="postgres" \
PGSQL_PASS="postgres" \
PGSQL_DB="pdns" \
PGSQL_VERSION="4.3.0" \
SQLITE_DB="pdns.sqlite3" \
SQLITE_VERSION="4.3.1" \
SCHEMA_VERSION_TABLE="_schema_version"

ENTRYPOINT ["/entrypoint.sh"]
EXPOSE 53/tcp 53/udp
ADD pdns.conf /etc/pdns/
ADD entrypoint.sh /bin/powerdns
ENTRYPOINT ["powerdns"]
58 changes: 54 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@

* Small Alpine based Image
* MySQL (default), Postgres, SQLite and Bind backend included
* Automatic migration of database schema (for MySQL, Postgres and SQLite)
* DNSSEC support optional
* Automatic MySQL database initialization
* Automatic database initialization for MySQL, Postgres and SQLite
* Latest PowerDNS version (if not pls file an issue)
* Guardian process enabled
* Graceful shutdown using pdns_control
Expand All @@ -21,6 +22,8 @@

## Usage

### MySQL

```shell
# Start a MySQL Container
$ docker run -d \
Expand All @@ -33,6 +36,7 @@ $ docker run --name pdns \
--link pdns-mysql:mysql \
-p 53:53 \
-p 53:53/udp \
-e AUTOCONF=mysql
-e MYSQL_USER=root \
-e MYSQL_PASS=supersecret \
-e MYSQL_PORT=3306 \
Expand All @@ -41,6 +45,40 @@ $ docker run --name pdns \
--allow-axfr-ips=127.0.0.1,123.1.2.3
```

### Postgres

```shell
# Start a Postgres Container
$ docker run -d \
--name pdns-postgres \
-e POSTGRES_PASSWORD=supersecret \
-v $PWD/postgres-data:/var/lib/postgresql \
postgres:9.6

$ docker run --name pdns \
--link pdns-postgres:postgres \
-p 53:53 \
-p 53:53/udp \
-e AUTOCONF=postgres \
-e PGSQL_USER=postgres \
-e PGSQL_PASS=supersecret \
psitrax/powerdns \
--cache-ttl=120 \
--allow-axfr-ips=127.0.0.1,123.1.2.3
```

### SQLite

```shell
$ docker run --name pdns \
-p 53:53 \
-p 53:53/udp \
-e AUTOCONF=sqlite \
psitrax/powerdns \
--cache-ttl=120 \
--allow-axfr-ips=127.0.0.1,123.1.2.3
```

## Configuration

**Environment Configuration:**
Expand All @@ -51,10 +89,22 @@ $ docker run --name pdns \
* `MYSQL_PASS=root`
* `MYSQL_DB=pdns`
* `MYSQL_DNSSEC=no`
* To support docker secrets, use same variables as above with suffix `_FILE`.
* Want to disable mysql initialization? Use `MYSQL_AUTOCONF=false`
* DNSSEC is disabled by default, to enable use `MYSQL_DNSSEC=yes`
* Postgres connection settings
* `PGSQL_HOST=mysql`
* `PGSQL_USER=root`
* `PGSQL_PASS=root`
* `PGSQL_DB=pdns`
* SQLite connection settings
* `SQLITE_DB=/pdns.sqlite3`
* DNSSEC is disabled by default, to enable use `DNSSEC=yes`
* Want to disable database initialization? Use `AUTOCONF=false`
* Want to disable automatic migration of database schema? Use `AUTO_SCHEMA_MIGRATION=no`
* If this option is enabled afterwards on an existing installation, set `INITIAL_DB_VERSION=x.y.z`
where x.y.z is the version of the schema currently installed on the database.
This variable can be safely removed once the database has been upgraded for the first time.
* Want to apply 12Factor-Pattern? Apply environment variables of the form `PDNS_$pdns-config-variable=$config-value`, like `PDNS_WEBSERVER=yes`
* Want to use own config files? Mount a Volume to `/etc/pdns/conf.d` or simply overwrite `/etc/pdns/pdns.conf`
* Use `TRACE=true` to debug the pdns config directives

**PowerDNS Configuration:**

Expand Down
Loading