Last active
December 31, 2023 16:02
-
-
Save casperklein/32d003dfb38c6fedce8b1c59b0a19b95 to your computer and use it in GitHub Desktop.
powerdns-auth, powerdns-recursor and powerdns-admin playground
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # # ? Initial Config | |
| # mkdir -p ./data/powerdns-{auth,auth-secondary,recursor,admin} | |
| # # get initial powerdns db | |
| # docker create --name pdns powerdns/pdns-auth-master | |
| # docker cp pdns:/var/lib/powerdns/pdns.sqlite3 ./data/powerdns-auth/pdns.sqlite3 | |
| # docker cp pdns:/var/lib/powerdns/pdns.sqlite3 ./data/powerdns-auth-secondary/pdns.sqlite3 | |
| # docker rm pdns | |
| # printf '%s\n' '#forward-zones=example.com=10.10.10.10:53' '#trace=on' '#dnssec=off' '#dnssec=process-no-validate' > ./data/powerdns-recursor/custom.conf | |
| # # make powerdns and powerdns-admin directorys writeable by container user | |
| # chmod -R 777 ./data/powerdns-* | |
| # # ? Backup | |
| # docker exec powerdns-auth bash -c 'cd /var/lib/powerdns && \ | |
| # sqlite3 pdns.sqlite3 .dump > pdns.sqlite3.dump && \ | |
| # > pdns-backup.sqlite3 && \ | |
| # sqlite3 pdns-backup.sqlite3 < pdns.sqlite3.dump && rm pdns.sqlite3.dump' | |
| # # ? Sync Primary & Secondary | |
| # docker compose stop powerdns-auth-secondary && \ | |
| # \cp -af data/powerdns-auth/pdns-backup.sqlite3 data/powerdns-auth-secondary/pdns.sqlite3 && \ | |
| # docker compose start powerdns-auth-secondary | |
| services: | |
| # master: | |
| # image: mariadb:latest | |
| # command: --log-bin --log-basename=mariadb | |
| # environment: | |
| # - MARIADB_ROOT_PASSWORD=pdns | |
| # - MARIADB_USER=pdns | |
| # - MARIADB_PASSWORD=pdns | |
| # - MARIADB_DATABASE=pdns | |
| # - MARIADB_REPLICATION_USER=repl | |
| # - MARIADB_REPLICATION_PASSWORD=replicationpass | |
| # healthcheck: | |
| # test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] | |
| # interval: 10s | |
| # timeout: 5s | |
| # retries: 3 | |
| # volumes: | |
| # - ./data/mariadb/db:/var/lib/mysql | |
| # - ./data/mariadb/init:/docker-entrypoint-initdb.d/:ro | |
| # depends_on: | |
| # prepare: | |
| # condition: service_completed_successfully | |
| # phpmyadmin: | |
| # image: phpmyadmin | |
| # restart: always | |
| # ports: | |
| # - 8080:80 | |
| # # https://github.com/phpmyadmin/docker#environment-variables-summary | |
| # environment: | |
| # - PMA_ARBITRARY=1 | |
| # - PMA_HOSTS=master #,replica | |
| # - PMA_USER=pdns | |
| # - PMA_PASSWORD=pdns | |
| prepare: | |
| image: powerdns/pdns-auth-master:latest | |
| container_name: prepare-powerdns | |
| entrypoint: ["/bin/bash", "-c"] | |
| volumes: | |
| - ./data:/data | |
| user: root | |
| command: | |
| - | | |
| set -e | |
| mkdir -vp /data/powerdns-{auth,auth-secondary,recursor,admin} | |
| [ ! -f /data/powerdns-auth/pdns.sqlite3 ] && cp -v /var/lib/powerdns/pdns.sqlite3 /data/powerdns-auth/pdns.sqlite3 | |
| [ ! -f /data/powerdns-auth-secondary/pdns.sqlite3 ] && cp -v /var/lib/powerdns/pdns.sqlite3 /data/powerdns-auth-secondary/pdns.sqlite3 | |
| chmod -R 777 /data/powerdns-* /data/powerdns-{auth,auth-secondary}/pdns.sqlite3 | |
| ############# mariadb | |
| # mkdir -vp /data/mariadb/{db,init} | |
| # apt update | |
| # apt -y install wget | |
| # wget -O /data/mariadb/init/schema.mysql.sql https://raw.githubusercontent.com/PowerDNS/pdns/rel/auth-4.8.x/modules/gmysqlbackend/schema.mysql.sql | |
| restart: no | |
| powerdns-auth: | |
| # command: | |
| # --launch=gmysql | |
| # --gmysql-host=10.10.10.99 | |
| # --gmysql-user=pdns | |
| # --gmysql-password=pdns | |
| # --gmysql-dbname=pdns | |
| image: powerdns/pdns-auth-master:latest | |
| container_name: powerdns-auth | |
| hostname: powerdns-auth | |
| volumes: | |
| - /etc/localtime:/etc/localtime:ro | |
| - ./data/powerdns-auth:/var/lib/powerdns | |
| # - ./data/custom.conf:/etc/powerdns/pdns.d/custom.conf:ro | |
| environment: | |
| - PDNS_AUTH_API_KEY=api | |
| ports: | |
| - "1053:53" | |
| - "1053:53/udp" | |
| # - "8081:8081" API | |
| restart: always | |
| stop_grace_period: 1m | |
| depends_on: | |
| prepare: | |
| condition: service_completed_successfully | |
| # master: | |
| # condition: service_healthy | |
| networks: | |
| default: | |
| ipv4_address: 10.10.10.10 | |
| powerdns-auth-secondary: | |
| image: powerdns/pdns-auth-master:latest | |
| container_name: powerdns-auth-secondary | |
| hostname: powerdns-auth-secondary | |
| volumes: | |
| - /etc/localtime:/etc/localtime:ro | |
| - ./data/powerdns-auth-secondary/pdns.sqlite3:/var/lib/powerdns/pdns.sqlite3 | |
| ports: | |
| - "2053:53" | |
| - "2053:53/udp" | |
| restart: always | |
| stop_grace_period: 1m | |
| depends_on: | |
| prepare: | |
| condition: service_completed_successfully | |
| networks: | |
| default: | |
| ipv4_address: 10.10.10.20 | |
| powerdns-recursor: | |
| image: powerdns/pdns-recursor-master:latest | |
| container_name: powerdns-recursor | |
| hostname: powerdns-recursor | |
| volumes: | |
| - /etc/localtime:/etc/localtime:ro | |
| # - ./data/powerdns-recursor/custom.conf:/etc/powerdns/recursor.d/custom.conf:ro # done via command: | |
| # environment: | |
| # - PDNS_RECURSOR_API_KEY= | |
| ports: | |
| - "53:53" | |
| - "53:53/udp" | |
| # - "8081:8081" API | |
| command: | |
| # https://doc.powerdns.com/recursor/settings.html | |
| # forward example.com to powerdns-auth | |
| # rest of queries goes to Cloudflare DNS | |
| --allow-from=0.0.0.0/0 | |
| --forward-zones=example.com=10.10.10.10:53 | |
| --forward-zones-recurse=.=1.1.1.1 | |
| --dnssec=off | |
| --trace=off | |
| restart: always | |
| stop_grace_period: 1m | |
| depends_on: | |
| - powerdns-auth | |
| # PDNS API URL: http://powerdns-auth:8081 | |
| # PDNS API KEY: api | |
| powerdns-admin: | |
| image: ngoduykhanh/powerdns-admin:latest | |
| container_name: powerdns-admin | |
| hostname: powerdns-admin | |
| volumes: | |
| - ./data/powerdns-admin:/data | |
| ports: | |
| - "80:80" | |
| environment: | |
| # https://github.com/PowerDNS-Admin/PowerDNS-Admin/blob/f6289d140cfa9f1c4ff9537d871ccbeec5483742/configs/docker_config.py#L8 (legal_envvars) | |
| - GUNICORN_TIMEOUT=60 | |
| - GUNICORN_WORKERS=2 | |
| # - GUNICORN_LOGLEVEL=DEBUG | |
| - OFFLINE_MODE=True # True for offline, False for external resources (google fonts etc.) | |
| # - SIGNUP_ENABLED=False # Or via GUI --> Settings/Authentication | |
| restart: always | |
| stop_grace_period: 1m | |
| depends_on: | |
| prepare: | |
| condition: service_completed_successfully | |
| networks: | |
| default: | |
| ipam: | |
| driver: default | |
| config: | |
| - subnet: "10.10.10.0/24" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment