From 950b86265fa7ee3c695f3b4a227ce90bbe92a704 Mon Sep 17 00:00:00 2001 From: Peter Schiffer <3899107+pschiffe@users.noreply.github.com> Date: Tue, 4 Jun 2024 00:28:32 +0200 Subject: [PATCH] Update Fedora and Alpine base images PDNS Recursor is now at version 5.0 and PDNS Alpine version at 4.9. PDNS Fedora version stays at 4.8 for now. --- README.md | 14 ++-- ansible-playbook-mysql.yml | 8 +- ansible-playbook-pgsql.yml | 6 +- docker-compose-mysql-ipv6.yml | 10 +-- docker-compose-mysql.yml | 10 +-- docker-compose-pgsql.yml | 8 +- examples/kubernetes/mariadb.yaml | 2 +- examples/kubernetes/master-daemonset.yaml | 2 +- examples/kubernetes/slave-daemonset.yaml | 6 +- pdns-mysql/Dockerfile | 2 +- pdns-mysql/Dockerfile.alpine | 4 +- pdns-mysql/docker-entrypoint.sh | 95 +++++++++++------------ pdns-pgsql/Dockerfile | 2 +- pdns-pgsql/Dockerfile.alpine | 4 +- pdns-pgsql/docker-entrypoint.sh | 45 +++++------ pdns-recursor/Dockerfile | 7 +- pdns-recursor/Dockerfile.alpine | 7 +- pdns-recursor/docker-entrypoint.sh | 20 ++--- 18 files changed, 121 insertions(+), 131 deletions(-) diff --git a/README.md b/README.md index e050c78..cd72832 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # PowerDNS Docker Images -This repository contains the following Docker images - pdns-mysql, pdns-pgsql, pdns-recursor and pdns-admin. Image **pdns-mysql** contains completely configurable [PowerDNS 4.x server](https://doc.powerdns.com/authoritative/) with mysql backend (without mysql server). Image **pdns-pgsql** contains completely configurable [PowerDNS 4.x server](https://doc.powerdns.com/authoritative/) with postgres backend (without postgres server). Image **pdns-recursor** contains completely configurable [PowerDNS 4.x recursor](https://doc.powerdns.com/recursor/). Image **pdns-admin** contains fronted (Caddy) and backend (uWSGI) for the [PowerDNS Admin](https://github.com/PowerDNS-Admin/PowerDNS-Admin) web app, which is written in Flask and used for managing PowerDNS servers. +This repository contains the following Docker images - pdns-mysql, pdns-pgsql, pdns-recursor and pdns-admin. Image **pdns-mysql** contains completely configurable [PowerDNS 4.x server](https://doc.powerdns.com/authoritative/) with mysql backend (without mysql server). Image **pdns-pgsql** contains completely configurable [PowerDNS 4.x server](https://doc.powerdns.com/authoritative/) with postgres backend (without postgres server). Image **pdns-recursor** contains completely configurable [PowerDNS 5.x recursor](https://doc.powerdns.com/recursor/). Image **pdns-admin** contains fronted (Caddy) and backend (uWSGI) for the [PowerDNS Admin](https://github.com/PowerDNS-Admin/PowerDNS-Admin) web app, which is written in Flask and used for managing PowerDNS servers. The pdns-mysql, pdns-pgsql and pdns-recursor images have also the `alpine` tag, thanks to @PoppyPop. @@ -52,7 +52,7 @@ Example of a master server with the API enabled and one slave server configured: ``` docker run -d -p 53:53 -p 53:53/udp --name pdns-master \ --hostname ns1.example.com --link mariadb:mysql \ - -e PDNS_master=yes \ + -e PDNS_primary=yes \ -e PDNS_api=yes \ -e PDNS_api_key=secret \ -e PDNS_webserver=yes \ @@ -70,7 +70,8 @@ Example of a slave server with a supermaster: docker run -d -p 53:53 -p 53:53/udp --name pdns-slave \ --hostname ns2.example.com --link mariadb:mysql \ -e PDNS_gmysql_dbname=powerdnsslave \ - -e PDNS_slave=yes \ + -e PDNS_secondary=yes \ + -e PDNS_autosecondary=yes \ -e PDNS_version_string=anonymous \ -e PDNS_disable_axfr=yes \ -e PDNS_allow_notify_from=172.5.0.20 \ @@ -109,7 +110,7 @@ Example of a master server with the API enabled and one slave server configured: ``` docker run -d -p 53:53 -p 53:53/udp --name pdns-master \ --hostname ns1.example.com --link postgres:pgsql \ - -e PDNS_master=yes \ + -e PDNS_primary=yes \ -e PDNS_api=yes \ -e PDNS_api_key=secret \ -e PDNS_webserver=yes \ @@ -127,7 +128,8 @@ Example of a slave server with a supermaster: docker run -d -p 53:53 -p 53:53/udp --name pdns-slave \ --hostname ns2.example.com --link postgres:pgsql \ -e PDNS_gpgsql_dbname=powerdnsslave \ - -e PDNS_slave=yes \ + -e PDNS_secondary=yes \ + -e PDNS_autosecondary=yes \ -e PDNS_version_string=anonymous \ -e PDNS_disable_axfr=yes \ -e PDNS_allow_notify_from=172.5.0.20 \ @@ -141,7 +143,7 @@ docker run -d -p 53:53 -p 53:53/udp --name pdns-slave \ https://hub.docker.com/r/pschiffe/pdns-recursor/ -Docker image with [PowerDNS 4.x recursor](https://doc.powerdns.com/recursor/). +Docker image with [PowerDNS 5.x recursor](https://doc.powerdns.com/recursor/). 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 away and every `_` will be replaced with `-`. For example, from the 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. diff --git a/ansible-playbook-mysql.yml b/ansible-playbook-mysql.yml index f1e5e32..b14a45d 100644 --- a/ansible-playbook-mysql.yml +++ b/ansible-playbook-mysql.yml @@ -64,7 +64,7 @@ - name: DB community.docker.docker_container: name: pdns-mariadb - image: mariadb:11 + image: mariadb:11-ubi pull: true state: '{{ c_state }}' networks: @@ -147,7 +147,7 @@ - /etc/localtime:/etc/localtime:ro env: PDNS_gmysql_password: 'my-secret-pw' - PDNS_master: 'yes' + PDNS_primary: 'yes' PDNS_api: 'yes' PDNS_api_key: 'secret' PDNS_webserver: 'yes' @@ -177,8 +177,8 @@ env: PDNS_gmysql_dbname: 'powerdnsslave' PDNS_gmysql_password: 'my-secret-pw' - PDNS_slave: 'yes' - PDNS_superslave: 'yes' + PDNS_secondary: 'yes' + PDNS_autosecondary: 'yes' PDNS_webserver: 'yes' PDNS_webserver_address: '0.0.0.0' PDNS_webserver_allow_from: '172.5.0.0/16' diff --git a/ansible-playbook-pgsql.yml b/ansible-playbook-pgsql.yml index 6442856..8f0d781 100644 --- a/ansible-playbook-pgsql.yml +++ b/ansible-playbook-pgsql.yml @@ -143,7 +143,7 @@ - /etc/localtime:/etc/localtime:ro env: PDNS_gpgsql_password: 'my-secret-pw' - PDNS_master: 'yes' + PDNS_primary: 'yes' PDNS_api: 'yes' PDNS_api_key: 'secret' PDNS_webserver: 'yes' @@ -173,8 +173,8 @@ env: PDNS_gpgsql_dbname: 'powerdnsslave' PDNS_gpgsql_password: 'my-secret-pw' - PDNS_slave: 'yes' - PDNS_superslave: 'yes' + PDNS_secondary: 'yes' + PDNS_autosecondary: 'yes' PDNS_webserver: 'yes' PDNS_webserver_address: '0.0.0.0' PDNS_webserver_allow_from: '172.7.0.0/16' diff --git a/docker-compose-mysql-ipv6.yml b/docker-compose-mysql-ipv6.yml index 2e7dc19..e64588d 100644 --- a/docker-compose-mysql-ipv6.yml +++ b/docker-compose-mysql-ipv6.yml @@ -1,5 +1,3 @@ -version: '2.4' - services: pdns-recursor-mysql: @@ -15,7 +13,7 @@ services: hard: 5000 mariadb: - image: mariadb:11 + image: mariadb:11-ubi networks: pdns-mysql: aliases: @@ -61,7 +59,7 @@ services: - /etc/localtime:/etc/localtime:ro environment: - PDNS_gmysql_password=my-secret-pw - - PDNS_master=yes + - PDNS_primary=yes - PDNS_api=yes - PDNS_api_key=secret - PDNS_webserver=yes @@ -88,8 +86,8 @@ services: environment: - PDNS_gmysql_dbname=powerdnsslave - PDNS_gmysql_password=my-secret-pw - - PDNS_slave=yes - - PDNS_superslave=yes + - PDNS_secondary=yes + - PDNS_autosecondary=yes - PDNS_webserver=yes - PDNS_webserver_address=0.0.0.0 - PDNS_webserver_allow_from=${NETWORK_IPV6_PREFIX}::/${NETWORK_IPV6_PREFIX_LENGTH} diff --git a/docker-compose-mysql.yml b/docker-compose-mysql.yml index bb90cfb..fba0472 100644 --- a/docker-compose-mysql.yml +++ b/docker-compose-mysql.yml @@ -1,5 +1,3 @@ -version: '2.4' - services: pdns-recursor-mysql: @@ -14,7 +12,7 @@ services: hard: 5000 mariadb: - image: mariadb:11 + image: mariadb:11-ubi networks: pdns-mysql: aliases: @@ -58,7 +56,7 @@ services: - /etc/localtime:/etc/localtime:ro environment: - PDNS_gmysql_password=my-secret-pw - - PDNS_master=yes + - PDNS_primary=yes - PDNS_api=yes - PDNS_api_key=secret - PDNS_webserver=yes @@ -85,8 +83,8 @@ services: environment: - PDNS_gmysql_dbname=powerdnsslave - PDNS_gmysql_password=my-secret-pw - - PDNS_slave=yes - - PDNS_superslave=yes + - PDNS_secondary=yes + - PDNS_autosecondary=yes - PDNS_webserver=yes - PDNS_webserver_address=0.0.0.0 - PDNS_webserver_allow_from=172.6.0.0/16 diff --git a/docker-compose-pgsql.yml b/docker-compose-pgsql.yml index c2b2401..000476a 100644 --- a/docker-compose-pgsql.yml +++ b/docker-compose-pgsql.yml @@ -1,5 +1,3 @@ -version: '2.4' - services: pdns-recursor-pgsql: @@ -54,7 +52,7 @@ services: - /etc/localtime:/etc/localtime:ro environment: - PDNS_gpgsql_password=my-secret-pw - - PDNS_master=yes + - PDNS_primary=yes - PDNS_api=yes - PDNS_api_key=secret - PDNS_webserver=yes @@ -81,8 +79,8 @@ services: environment: - PDNS_gpgsql_dbname=powerdnsslave - PDNS_gpgsql_password=my-secret-pw - - PDNS_slave=yes - - PDNS_superslave=yes + - PDNS_secondary=yes + - PDNS_autosecondary=yes - PDNS_webserver=yes - PDNS_webserver_address=0.0.0.0 - PDNS_webserver_allow_from=172.8.0.0/16 diff --git a/examples/kubernetes/mariadb.yaml b/examples/kubernetes/mariadb.yaml index 44dcd88..3fcde5b 100644 --- a/examples/kubernetes/mariadb.yaml +++ b/examples/kubernetes/mariadb.yaml @@ -27,7 +27,7 @@ spec: spec: containers: - name: mariadb-pdns - image: mariadb:11 + image: mariadb:11-ubi imagePullPolicy: Always env: - name: MYSQL_ROOT_PASSWORD diff --git a/examples/kubernetes/master-daemonset.yaml b/examples/kubernetes/master-daemonset.yaml index 5072ce7..7a215d2 100644 --- a/examples/kubernetes/master-daemonset.yaml +++ b/examples/kubernetes/master-daemonset.yaml @@ -51,7 +51,7 @@ spec: value: "master_" - name: PDNS_version_string value: "anonymous" - - name: PDNS_master + - name: PDNS_primary value: "yes" - name: PDNS_api value: "yes" diff --git a/examples/kubernetes/slave-daemonset.yaml b/examples/kubernetes/slave-daemonset.yaml index 79b46dd..c380fde 100644 --- a/examples/kubernetes/slave-daemonset.yaml +++ b/examples/kubernetes/slave-daemonset.yaml @@ -6,7 +6,7 @@ metadata: app.kubernetes.io/name: pdns-slave app.kubernetes.io/part-of: pdns app.kubernetes.io/component: slave - name: pdns-slave + name: pdns-slave spec: revisionHistoryLimit: 10 selector: @@ -53,9 +53,9 @@ spec: value: "anonymous" - name: PDNS_disable_axfr value: "yes" - - name: PDNS_slave + - name: PDNS_secondary value: "yes" - - name: PDNS_superslave + - name: PDNS_autosecondary value: "yes" - name: PDNS_allow_unsigned_supermaster value: "no" diff --git a/pdns-mysql/Dockerfile b/pdns-mysql/Dockerfile index fb728c7..c05e2ae 100644 --- a/pdns-mysql/Dockerfile +++ b/pdns-mysql/Dockerfile @@ -1,4 +1,4 @@ -FROM fedora:39 +FROM fedora:40 RUN arch=$([ "$(arch)" = 'aarch64' ] && echo -n 'arm64' || echo -n 'amd64') \ && echo 'install_weak_deps=False' >> /etc/dnf/dnf.conf \ diff --git a/pdns-mysql/Dockerfile.alpine b/pdns-mysql/Dockerfile.alpine index e10484c..cd9bb8f 100644 --- a/pdns-mysql/Dockerfile.alpine +++ b/pdns-mysql/Dockerfile.alpine @@ -1,4 +1,4 @@ -FROM alpine:3.19.1 +FROM alpine:3.20.0 RUN arch=$([ "$(arch)" = 'aarch64' ] && echo -n 'arm64' || echo -n 'amd64') \ && apk update \ @@ -17,7 +17,7 @@ RUN mkdir -p /run/pdns \ COPY pdns.conf.tpl docker-entrypoint.sh / -ENV VERSION=4.8 \ +ENV VERSION=4.9 \ PDNS_guardian=yes \ PDNS_setuid=pdns \ PDNS_setgid=pdns \ diff --git a/pdns-mysql/docker-entrypoint.sh b/pdns-mysql/docker-entrypoint.sh index 41014bb..ac891e8 100755 --- a/pdns-mysql/docker-entrypoint.sh +++ b/pdns-mysql/docker-entrypoint.sh @@ -4,20 +4,20 @@ set -eu ##### Function definitions #### - -function deriveMySQLSettingsFromExistingConfigFile { +deriveMySQLSettingsFromExistingConfigFile() { if [ ! -f /etc/pdns/pdns.conf ]; then echo "Use of existing file /etc/pdns/pdns.conf requested but file does not exist!" exit 1 fi - PDNS_gmysql_host=`sed -n 's/^gmysql-host=\(.*\)/\1/p' < /etc/pdns/pdns.conf` - PDNS_gmysql_port=`sed -n 's/^gmysql-port=\(.*\)/\1/p' < /etc/pdns/pdns.conf` - PDNS_gmysql_user=`sed -n 's/^gmysql-user=\(.*\)/\1/p' < /etc/pdns/pdns.conf` - PDNS_gmysql_password=`sed -n 's/^gmysql-password=\(.*\)/\1/p' < /etc/pdns/pdns.conf` - PDNS_gmysql_dbname=`sed -n 's/^gmysql-dbname=\(.*\)/\1/p' < /etc/pdns/pdns.conf` + + PDNS_gmysql_host=$(sed -n 's/^gmysql-host=\(.*\)/\1/p' < /etc/pdns/pdns.conf) + PDNS_gmysql_port=$(sed -n 's/^gmysql-port=\(.*\)/\1/p' < /etc/pdns/pdns.conf) + PDNS_gmysql_user=$(sed -n 's/^gmysql-user=\(.*\)/\1/p' < /etc/pdns/pdns.conf) + PDNS_gmysql_password=$(sed -n 's/^gmysql-password=\(.*\)/\1/p' < /etc/pdns/pdns.conf) + PDNS_gmysql_dbname=$(sed -n 's/^gmysql-dbname=\(.*\)/\1/p' < /etc/pdns/pdns.conf) } -function deriveMySQLSettingsFromEnvironment { +deriveMySQLSettingsFromEnvironment() { # Configure mysql env vars : "${PDNS_gmysql_host:=${MYSQL_ENV_MYSQL_HOST:-mysql}}" : "${PDNS_gmysql_port:=${MYSQL_ENV_MYSQL_PORT:-3306}}" @@ -27,42 +27,41 @@ function deriveMySQLSettingsFromEnvironment { fi : "${PDNS_gmysql_password:=${MYSQL_ENV_MYSQL_PASSWORD:-powerdns}}" : "${PDNS_gmysql_dbname:=${MYSQL_ENV_MYSQL_DATABASE:-powerdns}}" - + # Use first part of node name as database name suffix if [ "${NODE_NAME:-}" ]; then NODE_NAME=$(echo "${NODE_NAME}" | sed -e 's/\..*//' -e 's/-//') PDNS_gmysql_dbname="${PDNS_gmysql_dbname}${NODE_NAME}" fi - + export PDNS_gmysql_host PDNS_gmysql_port PDNS_gmysql_user PDNS_gmysql_password PDNS_gmysql_dbname } -function generateMySQLCommand { +generateMySQLCommand() { EXTRA='' - + # Password Auth if [ "${PDNS_gmysql_password}" ]; then EXTRA="${EXTRA} -p${PDNS_gmysql_password}" fi - + # Allow socket connections if [ "${PDNS_gmysql_socket:-}" ]; then export PDNS_gmysql_host='localhost' EXTRA="${EXTRA} --socket=${PDNS_gmysql_socket}" fi - + MYSQL_COMMAND="mysql -h ${PDNS_gmysql_host} -P ${PDNS_gmysql_port} -u ${PDNS_gmysql_user}${EXTRA}" } - -function createDatabaseIfRequested { +createDatabaseIfRequested() { # Initialize DB if needed if [ "${SKIP_DB_CREATE:-false}" != 'true' ]; then $MYSQL_COMMAND -e "CREATE DATABASE IF NOT EXISTS ${PDNS_gmysql_dbname}" fi } -function initDatabase { +initDatabase() { if [ "${SKIP_DB_INIT:-false}" != 'true' ]; then MYSQL_CHECK_IF_HAS_TABLE="SELECT COUNT(DISTINCT table_name) FROM information_schema.columns WHERE table_schema = '${PDNS_gmysql_dbname}';" MYSQL_NUM_TABLE=$($MYSQL_COMMAND --batch --skip-column-names -e "$MYSQL_CHECK_IF_HAS_TABLE") @@ -75,7 +74,7 @@ function initDatabase { fi } -function migrateDatabaseTo47 { +migrateDatabaseTo47() { # SQL migration to version 4.7 MYSQL_CHECK_IF_47="SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = '${PDNS_gmysql_dbname}' AND table_name = 'domains' AND column_name = 'options';" MYSQL_NUM_TABLE=$($MYSQL_COMMAND --batch --skip-column-names -e "$MYSQL_CHECK_IF_47") @@ -85,44 +84,43 @@ function migrateDatabaseTo47 { fi } -function initSuperslave { -if [ "${PDNS_superslave:-no}" = 'yes' ]; then - # Configure supermasters if needed - if [ "${SUPERMASTER_IPS:-}" ]; then - $MYSQL_COMMAND -D "$PDNS_gmysql_dbname" -e 'TRUNCATE supermasters;' - MYSQL_INSERT_SUPERMASTERS='' - if [ "${SUPERMASTER_COUNT:-0}" -eq 0 ]; then - SUPERMASTER_COUNT=10 - fi - i=1; while [ $i -le "${SUPERMASTER_COUNT}" ]; do - SUPERMASTER_HOST=$(echo "${SUPERMASTER_HOSTS:-}" | awk -v col="$i" '{ print $col }') - SUPERMASTER_IP=$(echo "${SUPERMASTER_IPS}" | awk -v col="$i" '{ print $col }') - if [ -z "${SUPERMASTER_HOST:-}" ]; then - SUPERMASTER_HOST=$(hostname -f) - fi - if [ "${SUPERMASTER_IP:-}" ]; then - MYSQL_INSERT_SUPERMASTERS="${MYSQL_INSERT_SUPERMASTERS} INSERT INTO supermasters VALUES('${SUPERMASTER_IP}', '${SUPERMASTER_HOST}', 'admin');" - fi - i=$(( i + 1 )) - done - $MYSQL_COMMAND -D "$PDNS_gmysql_dbname" -e "$MYSQL_INSERT_SUPERMASTERS" - fi -fi +initSuperslave() { + if [ "${PDNS_autosecondary:-no}" = 'yes' ] || [ "${PDNS_superslave:-no}" = 'yes' ]; then + # Configure supermasters if needed + if [ "${SUPERMASTER_IPS:-}" ]; then + $MYSQL_COMMAND -D "$PDNS_gmysql_dbname" -e 'TRUNCATE supermasters;' + MYSQL_INSERT_SUPERMASTERS='' + if [ "${SUPERMASTER_COUNT:-0}" -eq 0 ]; then + SUPERMASTER_COUNT=10 + fi + i=1; while [ $i -le "${SUPERMASTER_COUNT}" ]; do + SUPERMASTER_HOST=$(echo "${SUPERMASTER_HOSTS:-}" | awk -v col="$i" '{ print $col }') + SUPERMASTER_IP=$(echo "${SUPERMASTER_IPS}" | awk -v col="$i" '{ print $col }') + if [ -z "${SUPERMASTER_HOST:-}" ]; then + SUPERMASTER_HOST=$(hostname -f) + fi + if [ "${SUPERMASTER_IP:-}" ]; then + MYSQL_INSERT_SUPERMASTERS="${MYSQL_INSERT_SUPERMASTERS} INSERT INTO supermasters VALUES('${SUPERMASTER_IP}', '${SUPERMASTER_HOST}', 'admin');" + fi + i=$(( i + 1 )) + done + $MYSQL_COMMAND -D "$PDNS_gmysql_dbname" -e "$MYSQL_INSERT_SUPERMASTERS" + fi + fi } -function generateAndInstallConfigFileFromEnvironment { +generateAndInstallConfigFileFromEnvironment() { # Create config file from template subvars --prefix 'PDNS_' < '/pdns.conf.tpl' > '/etc/pdns/pdns.conf' } +#### End of function definitions, let's get to work ... -#### End of function definitions, let's get to work ... - -if [ ${USE_EXISTING_CONFIG_FILE:-false} = 'true' ]; then +if [ "${USE_EXISTING_CONFIG_FILE:-false}" = 'true' ]; then deriveMySQLSettingsFromExistingConfigFile else deriveMySQLSettingsFromEnvironment -fi +fi generateMySQLCommand @@ -132,17 +130,14 @@ until $MYSQL_COMMAND -e ';' ; do sleep 3 done - createDatabaseIfRequested initDatabase migrateDatabaseTo47 initSuperslave -if [ ${USE_EXISTING_CONFIG_FILE:-false} = 'false' ]; then +if [ "${USE_EXISTING_CONFIG_FILE:-false}" = 'false' ]; then echo "(re-)generating config file from environment variables" generateAndInstallConfigFileFromEnvironment fi exec "$@" - - diff --git a/pdns-pgsql/Dockerfile b/pdns-pgsql/Dockerfile index 36c714b..c8999f2 100644 --- a/pdns-pgsql/Dockerfile +++ b/pdns-pgsql/Dockerfile @@ -1,4 +1,4 @@ -FROM fedora:39 +FROM fedora:40 RUN arch=$([ "$(arch)" = 'aarch64' ] && echo -n 'arm64' || echo -n 'amd64') \ && echo 'install_weak_deps=False' >> /etc/dnf/dnf.conf \ diff --git a/pdns-pgsql/Dockerfile.alpine b/pdns-pgsql/Dockerfile.alpine index 2617441..426030d 100644 --- a/pdns-pgsql/Dockerfile.alpine +++ b/pdns-pgsql/Dockerfile.alpine @@ -1,4 +1,4 @@ -FROM alpine:3.19.1 +FROM alpine:3.20.0 RUN arch=$([ "$(arch)" = 'aarch64' ] && echo -n 'arm64' || echo -n 'amd64') \ && apk update \ @@ -17,7 +17,7 @@ RUN mkdir -p /run/pdns \ COPY pdns.conf.tpl docker-entrypoint.sh / -ENV VERSION=4.8 \ +ENV VERSION=4.9 \ PDNS_guardian=yes \ PDNS_setuid=pdns \ PDNS_setgid=pdns \ diff --git a/pdns-pgsql/docker-entrypoint.sh b/pdns-pgsql/docker-entrypoint.sh index 7db548a..058a98a 100755 --- a/pdns-pgsql/docker-entrypoint.sh +++ b/pdns-pgsql/docker-entrypoint.sh @@ -2,49 +2,50 @@ set -eu -function derivePostgreSQLSettingsFromExistingConfigFile { +##### Function definitions #### + +derivePostgreSQLSettingsFromExistingConfigFile() { if [ ! -f /etc/pdns/pdns.conf ]; then echo "Use of existing file /etc/pdns/pdns.conf requested but file does not exist!" exit 1 fi - PDNS_gpgsql_host=`sed -n 's/^gpgsql-host=\(.*\)/\1/p' < /etc/pdns/pdns.conf` - PDNS_gpgsql_port=`sed -n 's/^gpgsql-port=\(.*\)/\1/p' < /etc/pdns/pdns.conf` - PDNS_gpgsql_user=`sed -n 's/^gpgsql-user=\(.*\)/\1/p' < /etc/pdns/pdns.conf` - PDNS_gpgsql_password=`sed -n 's/^gpgsql-password=\(.*\)/\1/p' < /etc/pdns/pdns.conf` - PDNS_gpgsql_dbname=`sed -n 's/^gpgsql-dbname=\(.*\)/\1/p' < /etc/pdns/pdns.conf` + + PDNS_gpgsql_host=$(sed -n 's/^gpgsql-host=\(.*\)/\1/p' < /etc/pdns/pdns.conf) + PDNS_gpgsql_port=$(sed -n 's/^gpgsql-port=\(.*\)/\1/p' < /etc/pdns/pdns.conf) + PDNS_gpgsql_user=$(sed -n 's/^gpgsql-user=\(.*\)/\1/p' < /etc/pdns/pdns.conf) + PDNS_gpgsql_password=$(sed -n 's/^gpgsql-password=\(.*\)/\1/p' < /etc/pdns/pdns.conf) + PDNS_gpgsql_dbname=$(sed -n 's/^gpgsql-dbname=\(.*\)/\1/p' < /etc/pdns/pdns.conf) } -function derivePostgreSQLSettingsFromEnvironment { +derivePostgreSQLSettingsFromEnvironment() { # Configure gpgsql env vars : "${PDNS_gpgsql_host:=pgsql}" : "${PDNS_gpgsql_port:=5432}" : "${PDNS_gpgsql_user:=${PGSQL_ENV_POSTGRES_USER:-postgres}}" : "${PDNS_gpgsql_password:=${PGSQL_ENV_POSTGRES_PASSWORD:-powerdns}}" : "${PDNS_gpgsql_dbname:=${PGSQL_ENV_POSTGRES_DB:-powerdns}}" - + # Use first part of node name as database name suffix if [ "${NODE_NAME:-}" ]; then NODE_NAME=$(echo "${NODE_NAME}" | sed -e 's/\..*//' -e 's/-//') PDNS_gpgsql_dbname="${PDNS_gpgsql_dbname}${NODE_NAME}" fi - + export PDNS_gpgsql_host PDNS_gpgsql_port PDNS_gpgsql_user PDNS_gpgsql_password PDNS_gpgsql_dbname } - - -function generatePostgreSQLCommand { +generatePostgreSQLCommand() { PGSQL_COMMAND="psql -h ${PDNS_gpgsql_host} -p ${PDNS_gpgsql_port} -U ${PDNS_gpgsql_user}" } -function createDatabaseIfRequested { +createDatabaseIfRequested() { # Initialize DB if needed if [ "${SKIP_DB_CREATE:-false}" != 'true' ]; then echo "SELECT 'CREATE DATABASE ${PDNS_gpgsql_dbname}' WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = '${PDNS_gpgsql_dbname}')\gexec" | $PGSQL_COMMAND fi } -function initDatabase { +initDatabase() { if [ "${SKIP_DB_INIT:-false}" != 'true' ]; then PGSQL_CHECK_IF_HAS_TABLE="SELECT COUNT(DISTINCT table_name) FROM information_schema.columns WHERE table_catalog = '${PDNS_gpgsql_dbname}' AND table_schema = 'public';" PGSQL_NUM_TABLE=$($PGSQL_COMMAND -At -d "$PDNS_gpgsql_dbname" -c "$PGSQL_CHECK_IF_HAS_TABLE") @@ -54,11 +55,11 @@ function initDatabase { else echo "Database exists but already has tables, will not try to init"; fi - fi + fi } -function initSuperslave { - if [ "${PDNS_superslave:-no}" = 'yes' ]; then +initSuperslave() { + if [ "${PDNS_autosecondary:-no}" = 'yes' ] || [ "${PDNS_superslave:-no}" = 'yes' ]; then # Configure supermasters if needed if [ "${SUPERMASTER_IPS:-}" ]; then $PGSQL_COMMAND -d "$PDNS_gpgsql_dbname" -c 'TRUNCATE supermasters;' @@ -82,13 +83,14 @@ function initSuperslave { fi } -function generateAndInstallConfigFileFromEnvironment { +generateAndInstallConfigFileFromEnvironment() { # Create config file from template subvars --prefix 'PDNS_' < '/pdns.conf.tpl' > '/etc/pdns/pdns.conf' } -###End of function definitions -if [ ${USE_EXISTING_CONFIG_FILE:-false} = 'true' ]; then +#### End of function definitions, let's get to work ... + +if [ "${USE_EXISTING_CONFIG_FILE:-false}" = 'true' ]; then derivePostgreSQLSettingsFromExistingConfigFile else derivePostgreSQLSettingsFromEnvironment @@ -109,12 +111,11 @@ createDatabaseIfRequested initDatabase initSuperslave -if [ ${USE_EXISTING_CONFIG_FILE:-false} = 'false' ]; then +if [ "${USE_EXISTING_CONFIG_FILE:-false}" = 'false' ]; then echo "(re-)generating config file from environment variables" generateAndInstallConfigFileFromEnvironment fi - unset PGPASSWORD exec "$@" diff --git a/pdns-recursor/Dockerfile b/pdns-recursor/Dockerfile index 39dce9f..1449796 100644 --- a/pdns-recursor/Dockerfile +++ b/pdns-recursor/Dockerfile @@ -1,4 +1,4 @@ -FROM fedora:39 +FROM fedora:40 RUN arch=$([ "$(arch)" = 'aarch64' ] && echo -n 'arm64' || echo -n 'amd64') \ && echo 'install_weak_deps=False' >> /etc/dnf/dnf.conf \ @@ -15,10 +15,11 @@ RUN mkdir -p /etc/pdns-recursor/api.d /run/pdns-recursor \ COPY recursor.conf.tpl docker-entrypoint.sh / -ENV VERSION=4.9 \ +ENV VERSION=5.0 \ PDNS_setuid=pdns-recursor \ PDNS_setgid=pdns-recursor \ - PDNS_daemon=no + PDNS_daemon=no \ + PDNS_loglevel=5 EXPOSE 53 53/udp diff --git a/pdns-recursor/Dockerfile.alpine b/pdns-recursor/Dockerfile.alpine index 841c8e3..bf5a790 100644 --- a/pdns-recursor/Dockerfile.alpine +++ b/pdns-recursor/Dockerfile.alpine @@ -1,4 +1,4 @@ -FROM alpine:3.19.1 +FROM alpine:3.20.0 RUN arch=$([ "$(arch)" = 'aarch64' ] && echo -n 'arm64' || echo -n 'amd64') \ && apk update \ @@ -13,10 +13,11 @@ RUN mkdir -p /etc/pdns/api.d /var/run/pdns-recursor \ COPY recursor.conf.tpl docker-entrypoint.sh / -ENV VERSION=4.9 \ +ENV VERSION=5.0 \ PDNS_setuid=recursor \ PDNS_setgid=recursor \ - PDNS_daemon=no + PDNS_daemon=no \ + PDNS_loglevel=5 EXPOSE 53 53/udp diff --git a/pdns-recursor/docker-entrypoint.sh b/pdns-recursor/docker-entrypoint.sh index 7d9f63e..668a898 100755 --- a/pdns-recursor/docker-entrypoint.sh +++ b/pdns-recursor/docker-entrypoint.sh @@ -3,16 +3,17 @@ set -eu #### Function definitions -function deriveConfigValuesFromEnvrionement { + +deriveConfigValuesFromEnvrionement() { # Configure base vars : "${PDNS_local_port:=53}" : "${PDNS_local_address:=0.0.0.0}" : "${PDNS_allow_from:=0.0.0.0/0}" - + export PDNS_local_port PDNS_local_address PDNS_allow_from } -### end of function definitions +### End of function definitions if [ -f /etc/fedora-release ]; then config_file=/etc/pdns-recursor/recursor.conf @@ -22,18 +23,13 @@ elif [ -f /etc/alpine-release ]; then pdns_user=recursor fi -if [ ${USE_EXISTING_CONFIG_FILE:-false} = 'false' ]; then +if [ "${USE_EXISTING_CONFIG_FILE:-false}" = 'false' ]; then deriveConfigValuesFromEnvrionement - echo "generating config file from environment" + echo "Generating config file from environment" subvars --prefix 'PDNS_' < '/recursor.conf.tpl' > "${config_file}" chown "${pdns_user}:" "${config_file}" else - echo "using existing config file ${config_file}" -fi - -# Create config file from template - -# Fix config file ownership - + echo "Using existing config file ${config_file}" +fi exec "$@"