91 lines
3.2 KiB
YAML
91 lines
3.2 KiB
YAML
version: "3.9"
|
|
|
|
services:
|
|
powerdns:
|
|
image: ${PDNS_IMAGE:-powerdns/pdns:latest}
|
|
container_name: ${PDNS_CONTAINER_NAME:-powerdns}
|
|
restart: unless-stopped
|
|
|
|
# Die Umgebungsvariablen dienen jetzt nur noch als Futter für das Script
|
|
environment:
|
|
PDNS_API_KEY: ${PDNS_API_KEY:-changeme}
|
|
PDNS_API_ALLOW_FROM: ${PDNS_API_ALLOW_FROM:-0.0.0.0/0,::/0}
|
|
PDNS_LAUNCH: ${PDNS_LAUNCH:-gsqlite3}
|
|
PDNS_GSQLITE3_DATABASE: ${PDNS_GSQLITE3_DATABASE:-/data/pdns.sqlite3}
|
|
PDNS_GPGSQL_HOST: ${PDNS_GPGSQL_HOST:-}
|
|
PDNS_GPGSQL_PORT: ${PDNS_GPGSQL_PORT:-5432}
|
|
PDNS_GPGSQL_USER: ${PDNS_GPGSQL_USER:-}
|
|
PDNS_GPGSQL_PASSWORD: ${PDNS_GPGSQL_PASSWORD:-}
|
|
PDNS_GPGSQL_DBNAME: ${PDNS_GPGSQL_DBNAME:-}
|
|
PDNS_LOG_LEVEL: ${PDNS_LOG_LEVEL:-6}
|
|
|
|
entrypoint: ["/bin/sh","-lc"]
|
|
command:
|
|
- |
|
|
set -eu
|
|
mkdir -p /etc/powerdns/pdns.d
|
|
mkdir -p /var/run/pdns
|
|
|
|
# Den richtigen Pfad zu pdns_server finden
|
|
PDNS_BIN=$$(which pdns_server || echo "/usr/sbin/pdns_server")
|
|
|
|
# Erzeuge die API & Webserver Konfiguration
|
|
cat > /etc/powerdns/pdns.d/99-env.conf <<EOF
|
|
api=yes
|
|
webserver=yes
|
|
webserver-address=0.0.0.0
|
|
webserver-port=8081
|
|
api-key=$${PDNS_API_KEY}
|
|
webserver-allow-from=$${PDNS_API_ALLOW_FROM}
|
|
loglevel=$${PDNS_LOG_LEVEL}
|
|
launch=$${PDNS_LAUNCH}
|
|
EOF
|
|
|
|
# Backend Spezifika
|
|
if [ "$${PDNS_LAUNCH}" = "gsqlite3" ]; then
|
|
echo "gsqlite3-database=$${PDNS_GSQLITE3_DATABASE}" >> /etc/powerdns/pdns.d/99-env.conf
|
|
else
|
|
cat >> /etc/powerdns/pdns.d/99-env.conf <<EOF
|
|
gpgsql-host=$${PDNS_GPGSQL_HOST}
|
|
gpgsql-port=$${PDNS_GPGSQL_PORT}
|
|
gpgsql-dbname=$${PDNS_GPGSQL_DBNAME}
|
|
gpgsql-user=$${PDNS_GPGSQL_USER}
|
|
gpgsql-password=$${PDNS_GPGSQL_PASSWORD}
|
|
EOF
|
|
fi
|
|
|
|
echo "Generated config. Starting $$PDNS_BIN..."
|
|
# Hier nutzen wir jetzt die gefundene Variable $$PDNS_BIN
|
|
exec $$PDNS_BIN --daemon=no --guardian=no --control-console
|
|
|
|
|
|
volumes:
|
|
- ${PDNS_DATA_PATH:-pdns-data}:/data
|
|
|
|
networks:
|
|
- proxy
|
|
|
|
ports:
|
|
- "${PDNS_PUBLIC_IPV4:-0.0.0.0}:${PDNS_PUBLIC_PORT:-53}:53/tcp"
|
|
- "${PDNS_PUBLIC_IPV4:-0.0.0.0}:${PDNS_PUBLIC_PORT:-53}:53/udp"
|
|
- "[${PDNS_PUBLIC_IPV6:-::}]:${PDNS_PUBLIC_PORT6:-53}:53/tcp"
|
|
- "[${PDNS_PUBLIC_IPV6:-::}]:${PDNS_PUBLIC_PORT6:-53}:53/udp"
|
|
|
|
labels:
|
|
- "traefik.enable=true"
|
|
- "traefik.http.routers.powerdns.rule=Host(`${PDNS_TRAEFIK_HOST:-dns.example.com}`)"
|
|
- "traefik.http.routers.powerdns.entrypoints=${PDNS_TRAEFIK_ENTRYPOINT:-websecure}"
|
|
- "traefik.http.routers.powerdns.tls=true"
|
|
- "traefik.http.routers.powerdns.tls.certresolver=${PDNS_TRAEFIK_CERTRESOLVER:-letsencrypt}"
|
|
- "traefik.http.services.powerdns.loadbalancer.server.port=8081"
|
|
- "traefik.http.routers.powerdns-insecure.rule=Host(`${PDNS_TRAEFIK_HOST:-dns.example.com}`)"
|
|
- "traefik.http.routers.powerdns-insecure.entrypoints=web"
|
|
- "traefik.http.routers.powerdns-insecure.middlewares=powerdns-redirect"
|
|
- "traefik.http.middlewares.powerdns-redirect.redirectscheme.scheme=https"
|
|
|
|
volumes:
|
|
pdns-data:
|
|
|
|
networks:
|
|
proxy:
|
|
external: true |