mirror of
https://github.com/pschiffe/docker-pdns.git
synced 2024-11-10 18:57:56 +01:00
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:
parent
3ba3021b68
commit
950b86265f
18 changed files with 121 additions and 131 deletions
14
README.md
14
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.
|
||||
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -27,7 +27,7 @@ spec:
|
|||
spec:
|
||||
containers:
|
||||
- name: mariadb-pdns
|
||||
image: mariadb:11
|
||||
image: mariadb:11-ubi
|
||||
imagePullPolicy: Always
|
||||
env:
|
||||
- name: MYSQL_ROOT_PASSWORD
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -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}}"
|
||||
|
@ -37,7 +37,7 @@ function deriveMySQLSettingsFromEnvironment {
|
|||
export PDNS_gmysql_host PDNS_gmysql_port PDNS_gmysql_user PDNS_gmysql_password PDNS_gmysql_dbname
|
||||
}
|
||||
|
||||
function generateMySQLCommand {
|
||||
generateMySQLCommand() {
|
||||
EXTRA=''
|
||||
|
||||
# Password Auth
|
||||
|
@ -54,15 +54,14 @@ function generateMySQLCommand {
|
|||
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,8 +84,8 @@ function migrateDatabaseTo47 {
|
|||
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
|
||||
$MYSQL_COMMAND -D "$PDNS_gmysql_dbname" -e 'TRUNCATE supermasters;'
|
||||
|
@ -107,18 +106,17 @@ if [ "${PDNS_superslave:-no}" = 'yes' ]; then
|
|||
done
|
||||
$MYSQL_COMMAND -D "$PDNS_gmysql_dbname" -e "$MYSQL_INSERT_SUPERMASTERS"
|
||||
fi
|
||||
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 ...
|
||||
|
||||
if [ ${USE_EXISTING_CONFIG_FILE:-false} = 'true' ]; then
|
||||
if [ "${USE_EXISTING_CONFIG_FILE:-false}" = 'true' ]; then
|
||||
deriveMySQLSettingsFromExistingConfigFile
|
||||
else
|
||||
deriveMySQLSettingsFromEnvironment
|
||||
|
@ -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 "$@"
|
||||
|
||||
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -2,19 +2,22 @@
|
|||
|
||||
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}"
|
||||
|
@ -31,20 +34,18 @@ function derivePostgreSQLSettingsFromEnvironment {
|
|||
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")
|
||||
|
@ -57,8 +58,8 @@ function initDatabase {
|
|||
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 "$@"
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
set -eu
|
||||
|
||||
#### Function definitions
|
||||
function deriveConfigValuesFromEnvrionement {
|
||||
|
||||
deriveConfigValuesFromEnvrionement() {
|
||||
# Configure base vars
|
||||
: "${PDNS_local_port:=53}"
|
||||
: "${PDNS_local_address:=0.0.0.0}"
|
||||
|
@ -12,7 +13,7 @@ function deriveConfigValuesFromEnvrionement {
|
|||
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}"
|
||||
echo "Using existing config file ${config_file}"
|
||||
fi
|
||||
|
||||
# Create config file from template
|
||||
|
||||
# Fix config file ownership
|
||||
|
||||
|
||||
exec "$@"
|
||||
|
|
Loading…
Reference in a new issue