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.
This commit is contained in:
Peter Schiffer 2024-06-04 00:28:32 +02:00
parent 3ba3021b68
commit 950b86265f
No known key found for this signature in database
GPG key ID: F2A18AC34A008397
18 changed files with 121 additions and 131 deletions

View file

@ -1,6 +1,6 @@
# PowerDNS Docker Images # 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. 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 \ docker run -d -p 53:53 -p 53:53/udp --name pdns-master \
--hostname ns1.example.com --link mariadb:mysql \ --hostname ns1.example.com --link mariadb:mysql \
-e PDNS_master=yes \ -e PDNS_primary=yes \
-e PDNS_api=yes \ -e PDNS_api=yes \
-e PDNS_api_key=secret \ -e PDNS_api_key=secret \
-e PDNS_webserver=yes \ -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 \ docker run -d -p 53:53 -p 53:53/udp --name pdns-slave \
--hostname ns2.example.com --link mariadb:mysql \ --hostname ns2.example.com --link mariadb:mysql \
-e PDNS_gmysql_dbname=powerdnsslave \ -e PDNS_gmysql_dbname=powerdnsslave \
-e PDNS_slave=yes \ -e PDNS_secondary=yes \
-e PDNS_autosecondary=yes \
-e PDNS_version_string=anonymous \ -e PDNS_version_string=anonymous \
-e PDNS_disable_axfr=yes \ -e PDNS_disable_axfr=yes \
-e PDNS_allow_notify_from=172.5.0.20 \ -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 \ docker run -d -p 53:53 -p 53:53/udp --name pdns-master \
--hostname ns1.example.com --link postgres:pgsql \ --hostname ns1.example.com --link postgres:pgsql \
-e PDNS_master=yes \ -e PDNS_primary=yes \
-e PDNS_api=yes \ -e PDNS_api=yes \
-e PDNS_api_key=secret \ -e PDNS_api_key=secret \
-e PDNS_webserver=yes \ -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 \ docker run -d -p 53:53 -p 53:53/udp --name pdns-slave \
--hostname ns2.example.com --link postgres:pgsql \ --hostname ns2.example.com --link postgres:pgsql \
-e PDNS_gpgsql_dbname=powerdnsslave \ -e PDNS_gpgsql_dbname=powerdnsslave \
-e PDNS_slave=yes \ -e PDNS_secondary=yes \
-e PDNS_autosecondary=yes \
-e PDNS_version_string=anonymous \ -e PDNS_version_string=anonymous \
-e PDNS_disable_axfr=yes \ -e PDNS_disable_axfr=yes \
-e PDNS_allow_notify_from=172.5.0.20 \ -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/ 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. 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.

View file

@ -64,7 +64,7 @@
- name: DB - name: DB
community.docker.docker_container: community.docker.docker_container:
name: pdns-mariadb name: pdns-mariadb
image: mariadb:11 image: mariadb:11-ubi
pull: true pull: true
state: '{{ c_state }}' state: '{{ c_state }}'
networks: networks:
@ -147,7 +147,7 @@
- /etc/localtime:/etc/localtime:ro - /etc/localtime:/etc/localtime:ro
env: env:
PDNS_gmysql_password: 'my-secret-pw' PDNS_gmysql_password: 'my-secret-pw'
PDNS_master: 'yes' PDNS_primary: 'yes'
PDNS_api: 'yes' PDNS_api: 'yes'
PDNS_api_key: 'secret' PDNS_api_key: 'secret'
PDNS_webserver: 'yes' PDNS_webserver: 'yes'
@ -177,8 +177,8 @@
env: env:
PDNS_gmysql_dbname: 'powerdnsslave' PDNS_gmysql_dbname: 'powerdnsslave'
PDNS_gmysql_password: 'my-secret-pw' PDNS_gmysql_password: 'my-secret-pw'
PDNS_slave: 'yes' PDNS_secondary: 'yes'
PDNS_superslave: 'yes' PDNS_autosecondary: 'yes'
PDNS_webserver: 'yes' PDNS_webserver: 'yes'
PDNS_webserver_address: '0.0.0.0' PDNS_webserver_address: '0.0.0.0'
PDNS_webserver_allow_from: '172.5.0.0/16' PDNS_webserver_allow_from: '172.5.0.0/16'

View file

@ -143,7 +143,7 @@
- /etc/localtime:/etc/localtime:ro - /etc/localtime:/etc/localtime:ro
env: env:
PDNS_gpgsql_password: 'my-secret-pw' PDNS_gpgsql_password: 'my-secret-pw'
PDNS_master: 'yes' PDNS_primary: 'yes'
PDNS_api: 'yes' PDNS_api: 'yes'
PDNS_api_key: 'secret' PDNS_api_key: 'secret'
PDNS_webserver: 'yes' PDNS_webserver: 'yes'
@ -173,8 +173,8 @@
env: env:
PDNS_gpgsql_dbname: 'powerdnsslave' PDNS_gpgsql_dbname: 'powerdnsslave'
PDNS_gpgsql_password: 'my-secret-pw' PDNS_gpgsql_password: 'my-secret-pw'
PDNS_slave: 'yes' PDNS_secondary: 'yes'
PDNS_superslave: 'yes' PDNS_autosecondary: 'yes'
PDNS_webserver: 'yes' PDNS_webserver: 'yes'
PDNS_webserver_address: '0.0.0.0' PDNS_webserver_address: '0.0.0.0'
PDNS_webserver_allow_from: '172.7.0.0/16' PDNS_webserver_allow_from: '172.7.0.0/16'

View file

@ -1,5 +1,3 @@
version: '2.4'
services: services:
pdns-recursor-mysql: pdns-recursor-mysql:
@ -15,7 +13,7 @@ services:
hard: 5000 hard: 5000
mariadb: mariadb:
image: mariadb:11 image: mariadb:11-ubi
networks: networks:
pdns-mysql: pdns-mysql:
aliases: aliases:
@ -61,7 +59,7 @@ services:
- /etc/localtime:/etc/localtime:ro - /etc/localtime:/etc/localtime:ro
environment: environment:
- PDNS_gmysql_password=my-secret-pw - PDNS_gmysql_password=my-secret-pw
- PDNS_master=yes - PDNS_primary=yes
- PDNS_api=yes - PDNS_api=yes
- PDNS_api_key=secret - PDNS_api_key=secret
- PDNS_webserver=yes - PDNS_webserver=yes
@ -88,8 +86,8 @@ services:
environment: environment:
- PDNS_gmysql_dbname=powerdnsslave - PDNS_gmysql_dbname=powerdnsslave
- PDNS_gmysql_password=my-secret-pw - PDNS_gmysql_password=my-secret-pw
- PDNS_slave=yes - PDNS_secondary=yes
- PDNS_superslave=yes - PDNS_autosecondary=yes
- PDNS_webserver=yes - PDNS_webserver=yes
- PDNS_webserver_address=0.0.0.0 - PDNS_webserver_address=0.0.0.0
- PDNS_webserver_allow_from=${NETWORK_IPV6_PREFIX}::/${NETWORK_IPV6_PREFIX_LENGTH} - PDNS_webserver_allow_from=${NETWORK_IPV6_PREFIX}::/${NETWORK_IPV6_PREFIX_LENGTH}

View file

@ -1,5 +1,3 @@
version: '2.4'
services: services:
pdns-recursor-mysql: pdns-recursor-mysql:
@ -14,7 +12,7 @@ services:
hard: 5000 hard: 5000
mariadb: mariadb:
image: mariadb:11 image: mariadb:11-ubi
networks: networks:
pdns-mysql: pdns-mysql:
aliases: aliases:
@ -58,7 +56,7 @@ services:
- /etc/localtime:/etc/localtime:ro - /etc/localtime:/etc/localtime:ro
environment: environment:
- PDNS_gmysql_password=my-secret-pw - PDNS_gmysql_password=my-secret-pw
- PDNS_master=yes - PDNS_primary=yes
- PDNS_api=yes - PDNS_api=yes
- PDNS_api_key=secret - PDNS_api_key=secret
- PDNS_webserver=yes - PDNS_webserver=yes
@ -85,8 +83,8 @@ services:
environment: environment:
- PDNS_gmysql_dbname=powerdnsslave - PDNS_gmysql_dbname=powerdnsslave
- PDNS_gmysql_password=my-secret-pw - PDNS_gmysql_password=my-secret-pw
- PDNS_slave=yes - PDNS_secondary=yes
- PDNS_superslave=yes - PDNS_autosecondary=yes
- PDNS_webserver=yes - PDNS_webserver=yes
- PDNS_webserver_address=0.0.0.0 - PDNS_webserver_address=0.0.0.0
- PDNS_webserver_allow_from=172.6.0.0/16 - PDNS_webserver_allow_from=172.6.0.0/16

View file

@ -1,5 +1,3 @@
version: '2.4'
services: services:
pdns-recursor-pgsql: pdns-recursor-pgsql:
@ -54,7 +52,7 @@ services:
- /etc/localtime:/etc/localtime:ro - /etc/localtime:/etc/localtime:ro
environment: environment:
- PDNS_gpgsql_password=my-secret-pw - PDNS_gpgsql_password=my-secret-pw
- PDNS_master=yes - PDNS_primary=yes
- PDNS_api=yes - PDNS_api=yes
- PDNS_api_key=secret - PDNS_api_key=secret
- PDNS_webserver=yes - PDNS_webserver=yes
@ -81,8 +79,8 @@ services:
environment: environment:
- PDNS_gpgsql_dbname=powerdnsslave - PDNS_gpgsql_dbname=powerdnsslave
- PDNS_gpgsql_password=my-secret-pw - PDNS_gpgsql_password=my-secret-pw
- PDNS_slave=yes - PDNS_secondary=yes
- PDNS_superslave=yes - PDNS_autosecondary=yes
- PDNS_webserver=yes - PDNS_webserver=yes
- PDNS_webserver_address=0.0.0.0 - PDNS_webserver_address=0.0.0.0
- PDNS_webserver_allow_from=172.8.0.0/16 - PDNS_webserver_allow_from=172.8.0.0/16

View file

@ -27,7 +27,7 @@ spec:
spec: spec:
containers: containers:
- name: mariadb-pdns - name: mariadb-pdns
image: mariadb:11 image: mariadb:11-ubi
imagePullPolicy: Always imagePullPolicy: Always
env: env:
- name: MYSQL_ROOT_PASSWORD - name: MYSQL_ROOT_PASSWORD

View file

@ -51,7 +51,7 @@ spec:
value: "master_" value: "master_"
- name: PDNS_version_string - name: PDNS_version_string
value: "anonymous" value: "anonymous"
- name: PDNS_master - name: PDNS_primary
value: "yes" value: "yes"
- name: PDNS_api - name: PDNS_api
value: "yes" value: "yes"

View file

@ -53,9 +53,9 @@ spec:
value: "anonymous" value: "anonymous"
- name: PDNS_disable_axfr - name: PDNS_disable_axfr
value: "yes" value: "yes"
- name: PDNS_slave - name: PDNS_secondary
value: "yes" value: "yes"
- name: PDNS_superslave - name: PDNS_autosecondary
value: "yes" value: "yes"
- name: PDNS_allow_unsigned_supermaster - name: PDNS_allow_unsigned_supermaster
value: "no" value: "no"

View file

@ -1,4 +1,4 @@
FROM fedora:39 FROM fedora:40
RUN arch=$([ "$(arch)" = 'aarch64' ] && echo -n 'arm64' || echo -n 'amd64') \ RUN arch=$([ "$(arch)" = 'aarch64' ] && echo -n 'arm64' || echo -n 'amd64') \
&& echo 'install_weak_deps=False' >> /etc/dnf/dnf.conf \ && echo 'install_weak_deps=False' >> /etc/dnf/dnf.conf \

View file

@ -1,4 +1,4 @@
FROM alpine:3.19.1 FROM alpine:3.20.0
RUN arch=$([ "$(arch)" = 'aarch64' ] && echo -n 'arm64' || echo -n 'amd64') \ RUN arch=$([ "$(arch)" = 'aarch64' ] && echo -n 'arm64' || echo -n 'amd64') \
&& apk update \ && apk update \
@ -17,7 +17,7 @@ RUN mkdir -p /run/pdns \
COPY pdns.conf.tpl docker-entrypoint.sh / COPY pdns.conf.tpl docker-entrypoint.sh /
ENV VERSION=4.8 \ ENV VERSION=4.9 \
PDNS_guardian=yes \ PDNS_guardian=yes \
PDNS_setuid=pdns \ PDNS_setuid=pdns \
PDNS_setgid=pdns \ PDNS_setgid=pdns \

View file

@ -4,20 +4,20 @@ set -eu
##### Function definitions #### ##### Function definitions ####
deriveMySQLSettingsFromExistingConfigFile() {
function deriveMySQLSettingsFromExistingConfigFile {
if [ ! -f /etc/pdns/pdns.conf ]; then if [ ! -f /etc/pdns/pdns.conf ]; then
echo "Use of existing file /etc/pdns/pdns.conf requested but file does not exist!" echo "Use of existing file /etc/pdns/pdns.conf requested but file does not exist!"
exit 1 exit 1
fi 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_host=$(sed -n 's/^gmysql-host=\(.*\)/\1/p' < /etc/pdns/pdns.conf)
PDNS_gmysql_user=`sed -n 's/^gmysql-user=\(.*\)/\1/p' < /etc/pdns/pdns.conf` PDNS_gmysql_port=$(sed -n 's/^gmysql-port=\(.*\)/\1/p' < /etc/pdns/pdns.conf)
PDNS_gmysql_password=`sed -n 's/^gmysql-password=\(.*\)/\1/p' < /etc/pdns/pdns.conf` PDNS_gmysql_user=$(sed -n 's/^gmysql-user=\(.*\)/\1/p' < /etc/pdns/pdns.conf)
PDNS_gmysql_dbname=`sed -n 's/^gmysql-dbname=\(.*\)/\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 # Configure mysql env vars
: "${PDNS_gmysql_host:=${MYSQL_ENV_MYSQL_HOST:-mysql}}" : "${PDNS_gmysql_host:=${MYSQL_ENV_MYSQL_HOST:-mysql}}"
: "${PDNS_gmysql_port:=${MYSQL_ENV_MYSQL_PORT:-3306}}" : "${PDNS_gmysql_port:=${MYSQL_ENV_MYSQL_PORT:-3306}}"
@ -37,7 +37,7 @@ function deriveMySQLSettingsFromEnvironment {
export PDNS_gmysql_host PDNS_gmysql_port PDNS_gmysql_user PDNS_gmysql_password PDNS_gmysql_dbname export PDNS_gmysql_host PDNS_gmysql_port PDNS_gmysql_user PDNS_gmysql_password PDNS_gmysql_dbname
} }
function generateMySQLCommand { generateMySQLCommand() {
EXTRA='' EXTRA=''
# Password Auth # Password Auth
@ -54,15 +54,14 @@ function generateMySQLCommand {
MYSQL_COMMAND="mysql -h ${PDNS_gmysql_host} -P ${PDNS_gmysql_port} -u ${PDNS_gmysql_user}${EXTRA}" MYSQL_COMMAND="mysql -h ${PDNS_gmysql_host} -P ${PDNS_gmysql_port} -u ${PDNS_gmysql_user}${EXTRA}"
} }
createDatabaseIfRequested() {
function createDatabaseIfRequested {
# Initialize DB if needed # Initialize DB if needed
if [ "${SKIP_DB_CREATE:-false}" != 'true' ]; then if [ "${SKIP_DB_CREATE:-false}" != 'true' ]; then
$MYSQL_COMMAND -e "CREATE DATABASE IF NOT EXISTS ${PDNS_gmysql_dbname}" $MYSQL_COMMAND -e "CREATE DATABASE IF NOT EXISTS ${PDNS_gmysql_dbname}"
fi fi
} }
function initDatabase { initDatabase() {
if [ "${SKIP_DB_INIT:-false}" != 'true' ]; then 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_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") MYSQL_NUM_TABLE=$($MYSQL_COMMAND --batch --skip-column-names -e "$MYSQL_CHECK_IF_HAS_TABLE")
@ -75,7 +74,7 @@ function initDatabase {
fi fi
} }
function migrateDatabaseTo47 { migrateDatabaseTo47() {
# SQL migration to version 4.7 # 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_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") MYSQL_NUM_TABLE=$($MYSQL_COMMAND --batch --skip-column-names -e "$MYSQL_CHECK_IF_47")
@ -85,8 +84,8 @@ function migrateDatabaseTo47 {
fi fi
} }
function initSuperslave { initSuperslave() {
if [ "${PDNS_superslave:-no}" = 'yes' ]; then if [ "${PDNS_autosecondary:-no}" = 'yes' ] || [ "${PDNS_superslave:-no}" = 'yes' ]; then
# Configure supermasters if needed # Configure supermasters if needed
if [ "${SUPERMASTER_IPS:-}" ]; then if [ "${SUPERMASTER_IPS:-}" ]; then
$MYSQL_COMMAND -D "$PDNS_gmysql_dbname" -e 'TRUNCATE supermasters;' $MYSQL_COMMAND -D "$PDNS_gmysql_dbname" -e 'TRUNCATE supermasters;'
@ -107,18 +106,17 @@ if [ "${PDNS_superslave:-no}" = 'yes' ]; then
done done
$MYSQL_COMMAND -D "$PDNS_gmysql_dbname" -e "$MYSQL_INSERT_SUPERMASTERS" $MYSQL_COMMAND -D "$PDNS_gmysql_dbname" -e "$MYSQL_INSERT_SUPERMASTERS"
fi fi
fi fi
} }
function generateAndInstallConfigFileFromEnvironment { generateAndInstallConfigFileFromEnvironment() {
# Create config file from template # Create config file from template
subvars --prefix 'PDNS_' < '/pdns.conf.tpl' > '/etc/pdns/pdns.conf' 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 deriveMySQLSettingsFromExistingConfigFile
else else
deriveMySQLSettingsFromEnvironment deriveMySQLSettingsFromEnvironment
@ -132,17 +130,14 @@ until $MYSQL_COMMAND -e ';' ; do
sleep 3 sleep 3
done done
createDatabaseIfRequested createDatabaseIfRequested
initDatabase initDatabase
migrateDatabaseTo47 migrateDatabaseTo47
initSuperslave 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" echo "(re-)generating config file from environment variables"
generateAndInstallConfigFileFromEnvironment generateAndInstallConfigFileFromEnvironment
fi fi
exec "$@" exec "$@"

View file

@ -1,4 +1,4 @@
FROM fedora:39 FROM fedora:40
RUN arch=$([ "$(arch)" = 'aarch64' ] && echo -n 'arm64' || echo -n 'amd64') \ RUN arch=$([ "$(arch)" = 'aarch64' ] && echo -n 'arm64' || echo -n 'amd64') \
&& echo 'install_weak_deps=False' >> /etc/dnf/dnf.conf \ && echo 'install_weak_deps=False' >> /etc/dnf/dnf.conf \

View file

@ -1,4 +1,4 @@
FROM alpine:3.19.1 FROM alpine:3.20.0
RUN arch=$([ "$(arch)" = 'aarch64' ] && echo -n 'arm64' || echo -n 'amd64') \ RUN arch=$([ "$(arch)" = 'aarch64' ] && echo -n 'arm64' || echo -n 'amd64') \
&& apk update \ && apk update \
@ -17,7 +17,7 @@ RUN mkdir -p /run/pdns \
COPY pdns.conf.tpl docker-entrypoint.sh / COPY pdns.conf.tpl docker-entrypoint.sh /
ENV VERSION=4.8 \ ENV VERSION=4.9 \
PDNS_guardian=yes \ PDNS_guardian=yes \
PDNS_setuid=pdns \ PDNS_setuid=pdns \
PDNS_setgid=pdns \ PDNS_setgid=pdns \

View file

@ -2,19 +2,22 @@
set -eu set -eu
function derivePostgreSQLSettingsFromExistingConfigFile { ##### Function definitions ####
derivePostgreSQLSettingsFromExistingConfigFile() {
if [ ! -f /etc/pdns/pdns.conf ]; then if [ ! -f /etc/pdns/pdns.conf ]; then
echo "Use of existing file /etc/pdns/pdns.conf requested but file does not exist!" echo "Use of existing file /etc/pdns/pdns.conf requested but file does not exist!"
exit 1 exit 1
fi 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_host=$(sed -n 's/^gpgsql-host=\(.*\)/\1/p' < /etc/pdns/pdns.conf)
PDNS_gpgsql_user=`sed -n 's/^gpgsql-user=\(.*\)/\1/p' < /etc/pdns/pdns.conf` PDNS_gpgsql_port=$(sed -n 's/^gpgsql-port=\(.*\)/\1/p' < /etc/pdns/pdns.conf)
PDNS_gpgsql_password=`sed -n 's/^gpgsql-password=\(.*\)/\1/p' < /etc/pdns/pdns.conf` PDNS_gpgsql_user=$(sed -n 's/^gpgsql-user=\(.*\)/\1/p' < /etc/pdns/pdns.conf)
PDNS_gpgsql_dbname=`sed -n 's/^gpgsql-dbname=\(.*\)/\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 # Configure gpgsql env vars
: "${PDNS_gpgsql_host:=pgsql}" : "${PDNS_gpgsql_host:=pgsql}"
: "${PDNS_gpgsql_port:=5432}" : "${PDNS_gpgsql_port:=5432}"
@ -31,20 +34,18 @@ function derivePostgreSQLSettingsFromEnvironment {
export PDNS_gpgsql_host PDNS_gpgsql_port PDNS_gpgsql_user PDNS_gpgsql_password PDNS_gpgsql_dbname export PDNS_gpgsql_host PDNS_gpgsql_port PDNS_gpgsql_user PDNS_gpgsql_password PDNS_gpgsql_dbname
} }
generatePostgreSQLCommand() {
function generatePostgreSQLCommand {
PGSQL_COMMAND="psql -h ${PDNS_gpgsql_host} -p ${PDNS_gpgsql_port} -U ${PDNS_gpgsql_user}" PGSQL_COMMAND="psql -h ${PDNS_gpgsql_host} -p ${PDNS_gpgsql_port} -U ${PDNS_gpgsql_user}"
} }
function createDatabaseIfRequested { createDatabaseIfRequested() {
# Initialize DB if needed # Initialize DB if needed
if [ "${SKIP_DB_CREATE:-false}" != 'true' ]; then 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 echo "SELECT 'CREATE DATABASE ${PDNS_gpgsql_dbname}' WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = '${PDNS_gpgsql_dbname}')\gexec" | $PGSQL_COMMAND
fi fi
} }
function initDatabase { initDatabase() {
if [ "${SKIP_DB_INIT:-false}" != 'true' ]; then 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_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") PGSQL_NUM_TABLE=$($PGSQL_COMMAND -At -d "$PDNS_gpgsql_dbname" -c "$PGSQL_CHECK_IF_HAS_TABLE")
@ -57,8 +58,8 @@ function initDatabase {
fi fi
} }
function initSuperslave { initSuperslave() {
if [ "${PDNS_superslave:-no}" = 'yes' ]; then if [ "${PDNS_autosecondary:-no}" = 'yes' ] || [ "${PDNS_superslave:-no}" = 'yes' ]; then
# Configure supermasters if needed # Configure supermasters if needed
if [ "${SUPERMASTER_IPS:-}" ]; then if [ "${SUPERMASTER_IPS:-}" ]; then
$PGSQL_COMMAND -d "$PDNS_gpgsql_dbname" -c 'TRUNCATE supermasters;' $PGSQL_COMMAND -d "$PDNS_gpgsql_dbname" -c 'TRUNCATE supermasters;'
@ -82,13 +83,14 @@ function initSuperslave {
fi fi
} }
function generateAndInstallConfigFileFromEnvironment { generateAndInstallConfigFileFromEnvironment() {
# Create config file from template # Create config file from template
subvars --prefix 'PDNS_' < '/pdns.conf.tpl' > '/etc/pdns/pdns.conf' 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 derivePostgreSQLSettingsFromExistingConfigFile
else else
derivePostgreSQLSettingsFromEnvironment derivePostgreSQLSettingsFromEnvironment
@ -109,12 +111,11 @@ createDatabaseIfRequested
initDatabase initDatabase
initSuperslave 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" echo "(re-)generating config file from environment variables"
generateAndInstallConfigFileFromEnvironment generateAndInstallConfigFileFromEnvironment
fi fi
unset PGPASSWORD unset PGPASSWORD
exec "$@" exec "$@"

View file

@ -1,4 +1,4 @@
FROM fedora:39 FROM fedora:40
RUN arch=$([ "$(arch)" = 'aarch64' ] && echo -n 'arm64' || echo -n 'amd64') \ RUN arch=$([ "$(arch)" = 'aarch64' ] && echo -n 'arm64' || echo -n 'amd64') \
&& echo 'install_weak_deps=False' >> /etc/dnf/dnf.conf \ && 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 / COPY recursor.conf.tpl docker-entrypoint.sh /
ENV VERSION=4.9 \ ENV VERSION=5.0 \
PDNS_setuid=pdns-recursor \ PDNS_setuid=pdns-recursor \
PDNS_setgid=pdns-recursor \ PDNS_setgid=pdns-recursor \
PDNS_daemon=no PDNS_daemon=no \
PDNS_loglevel=5
EXPOSE 53 53/udp EXPOSE 53 53/udp

View file

@ -1,4 +1,4 @@
FROM alpine:3.19.1 FROM alpine:3.20.0
RUN arch=$([ "$(arch)" = 'aarch64' ] && echo -n 'arm64' || echo -n 'amd64') \ RUN arch=$([ "$(arch)" = 'aarch64' ] && echo -n 'arm64' || echo -n 'amd64') \
&& apk update \ && apk update \
@ -13,10 +13,11 @@ RUN mkdir -p /etc/pdns/api.d /var/run/pdns-recursor \
COPY recursor.conf.tpl docker-entrypoint.sh / COPY recursor.conf.tpl docker-entrypoint.sh /
ENV VERSION=4.9 \ ENV VERSION=5.0 \
PDNS_setuid=recursor \ PDNS_setuid=recursor \
PDNS_setgid=recursor \ PDNS_setgid=recursor \
PDNS_daemon=no PDNS_daemon=no \
PDNS_loglevel=5
EXPOSE 53 53/udp EXPOSE 53 53/udp

View file

@ -3,7 +3,8 @@
set -eu set -eu
#### Function definitions #### Function definitions
function deriveConfigValuesFromEnvrionement {
deriveConfigValuesFromEnvrionement() {
# Configure base vars # Configure base vars
: "${PDNS_local_port:=53}" : "${PDNS_local_port:=53}"
: "${PDNS_local_address:=0.0.0.0}" : "${PDNS_local_address:=0.0.0.0}"
@ -12,7 +13,7 @@ function deriveConfigValuesFromEnvrionement {
export PDNS_local_port PDNS_local_address PDNS_allow_from export PDNS_local_port PDNS_local_address PDNS_allow_from
} }
### end of function definitions ### End of function definitions
if [ -f /etc/fedora-release ]; then if [ -f /etc/fedora-release ]; then
config_file=/etc/pdns-recursor/recursor.conf config_file=/etc/pdns-recursor/recursor.conf
@ -22,18 +23,13 @@ elif [ -f /etc/alpine-release ]; then
pdns_user=recursor pdns_user=recursor
fi fi
if [ ${USE_EXISTING_CONFIG_FILE:-false} = 'false' ]; then if [ "${USE_EXISTING_CONFIG_FILE:-false}" = 'false' ]; then
deriveConfigValuesFromEnvrionement deriveConfigValuesFromEnvrionement
echo "generating config file from environment" echo "Generating config file from environment"
subvars --prefix 'PDNS_' < '/recursor.conf.tpl' > "${config_file}" subvars --prefix 'PDNS_' < '/recursor.conf.tpl' > "${config_file}"
chown "${pdns_user}:" "${config_file}" chown "${pdns_user}:" "${config_file}"
else else
echo "using existing config file ${config_file}" echo "Using existing config file ${config_file}"
fi fi
# Create config file from template
# Fix config file ownership
exec "$@" exec "$@"