feat: conditional BIND startup; config search path priority fix 🔧

- entrypoint: only start named when a bind backend is configured and
  enabled in app.yml; CoreDNS-only deployments skip named entirely
- config: user-supplied paths (/etc/directdnsonly, ./config) now
  searched before the bundled app.yml so mounted configs take effect
- docs: deployment topology reference — Topology A (dual BIND HA) and
  Topology B (single instance, multi-DC CoreDNS MySQL)
- chore: bump version to 2.1.0
- justfile: add build-docker recipe
This commit is contained in:
2026-02-19 12:07:37 +13:00
parent aac7b365a5
commit ae1e89a236
6 changed files with 184 additions and 13 deletions

View File

@@ -1,12 +1,44 @@
#!/bin/bash
set -e
# Start BIND
/usr/sbin/named -u bind -f &
# ---------------------------------------------------------------------------
# Detect whether any bind backend is configured and enabled.
# Uses the same config search order as the application itself.
# ---------------------------------------------------------------------------
BIND_ENABLED=$(python3 - <<'EOF'
import yaml, sys, os
## Initialize MySQL schema if needed
#if [ -f /app/schema/coredns_mysql.sql ]; then
# mysql -h mysql -u root -prootpassword coredns < /app/schema/coredns_mysql.sql
#fi
config_paths = [
"/etc/directdnsonly/app.yml",
"/etc/directdnsonly/app.yaml",
"/app/app.yml",
"/app/app.yaml",
"/app/config/app.yml",
"/app/config/app.yaml",
]
config = {}
for path in config_paths:
if os.path.exists(path):
with open(path) as f:
config = yaml.safe_load(f) or {}
break
backends = config.get("dns", {}).get("backends", {})
for cfg in backends.values():
if isinstance(cfg, dict) and cfg.get("type") == "bind" and cfg.get("enabled", False):
print("true")
sys.exit(0)
print("false")
EOF
)
if [ "$BIND_ENABLED" = "true" ]; then
echo "[entrypoint] BIND backend enabled — starting named"
/usr/sbin/named -u bind -f &
else
echo "[entrypoint] No BIND backend configured — skipping named"
fi
# Start the application
poetry run python directdnsonly/main.py
exec python -m directdnsonly