coredns-powerdns-api-wrapper deployment

This commit is contained in:
bryanpedini committed 2026-11-21 19:52:27 +01:00
1 parent e44eb6844a
commit 8959cabd67
4 files changed
+92

No files matched your search

+1
View File
@@ -0,0 +1 @@
.env
+29
View File
@@ -1 +1,30 @@
# coredns-powerdns-api-wrapper Deployment # coredns-powerdns-api-wrapper Deployment
PowerDNS Authoritative API subset used by acme.sh `dns_pdns`, backed by the records table of the CoreDNS `mysql` plugin: [source/coredns-powerdns-api-wrapper](https://git.bjphoster.com/source/coredns-powerdns-api-wrapper).
Every `/api/v1` call requires `X-API-Key`. `/healthz` is an unauthenticated check that pings MySQL; `/version` reports the running version. The binary starts as root and drops to `PUID`/`PGID` itself, so the compose sets no `user:`. It keeps no local state and needs no volume.
## Requirements
- MySQL or MariaDB holding the plugin's `<prefix>records` table. The application never creates or alters it. `CPAW_TABLE_PREFIX` must match the plugin's `table_prefix`.
- A dedicated database user limited to the statements the service runs (`SELECT`, plus `DELETE` and `INSERT` inside one transaction per PATCH):
```sql
CREATE USER 'corednsapi'@'%' IDENTIFIED BY '<password>';
GRANT SELECT, INSERT, DELETE ON `coredns`.`coredns_records` TO 'corednsapi'@'%';
```
## Usage
```sh
cp env.example .env
# edit .env
docker compose up -d
```
`MYSQL_DSN` is built from the `CPAW_DB_*` variables. Wrap `CPAW_DB_PASSWORD` in single quotes in `.env` if it contains `$`, otherwise Compose interpolates it.
acme.sh connects with `PDNS_Url=https://pdnsapi.example.com`, `PDNS_ServerId` set to `CPAW_PDNS_SERVER_ID` and `PDNS_Token` set to `CPAW_PDNS_API_KEY`.
## Update
Set `CPAW_VERSION` in `.env`, then:
```sh
docker compose pull
docker compose up -d
```
+37
View File
@@ -0,0 +1,37 @@
---
services:
coredns-powerdns-api-wrapper:
image: git.bjphoster.com/source/coredns-powerdns-api-wrapper:${CPAW_VERSION}
restart: unless-stopped
stop_grace_period: 30s
environment:
- LISTEN_ADDR=:${TRAEFIK_SERVICE_PORT}
- MYSQL_DSN=${CPAW_DB_USER}:${CPAW_DB_PASSWORD}@tcp(${CPAW_DB_HOST}:${CPAW_DB_PORT})/${CPAW_DB_NAME}?parseTime=true
- TABLE_PREFIX=${CPAW_TABLE_PREFIX}
- PDNS_API_KEY=${CPAW_PDNS_API_KEY}
- PDNS_SERVER_ID=${CPAW_PDNS_SERVER_ID}
- DEFAULT_TTL=${CPAW_DEFAULT_TTL}
- LOG_LEVEL=${CPAW_LOG_LEVEL}
- PUID=${CPAW_PUID}
- PGID=${CPAW_PGID}
labels:
### Section Træfik
- traefik.enable=${TRAEFIK_ENABLED}
- traefik.docker.network=${TRAEFIK_NETWORK}
# HTTPS
- traefik.http.routers.https-${TRAEFIK_ROUTER}.entrypoints=https
# configure the exposed service
- traefik.http.routers.https-${TRAEFIK_ROUTER}.middlewares=${TRAEFIK_MIDDLEWARES}
- traefik.http.routers.https-${TRAEFIK_ROUTER}.rule=${TRAEFIK_MATCHRULE}
# enable TLS and its certificate provider
- traefik.http.routers.https-${TRAEFIK_ROUTER}.tls=${TRAEFIK_TLSENABLED}
- traefik.http.routers.https-${TRAEFIK_ROUTER}.tls.certresolver=${TRAEFIK_CERTRESOLVER}
# specify a service so a custom port can be used
- traefik.http.services.${TRAEFIK_SERVICE}.loadbalancer.server.port=${TRAEFIK_SERVICE_PORT}
networks:
- traefik
networks:
traefik:
external: true
name: ${TRAEFIK_NETWORK}
+25
View File
@@ -0,0 +1,25 @@
# Træfik
TRAEFIK_ENABLED=true
TRAEFIK_NETWORK=traefik
TRAEFIK_ROUTER=pdnsapi_example_com
TRAEFIK_SERVICE=pdnsapi_example_com
TRAEFIK_SERVICE_PORT=3000
TRAEFIK_MATCHRULE=Host(`pdnsapi.example.com`)
TRAEFIK_TLSENABLED=true
TRAEFIK_CERTRESOLVER=letsencrypt
TRAEFIK_MIDDLEWARES=hsts
# coredns-powerdns-api-wrapper
CPAW_VERSION=1.0.0
CPAW_DB_HOST=mysql.example.com
CPAW_DB_PORT=3306
CPAW_DB_USER=corednsapi
CPAW_DB_PASSWORD=changeme
CPAW_DB_NAME=coredns
CPAW_TABLE_PREFIX=coredns_
CPAW_PDNS_API_KEY=changeme
CPAW_PDNS_SERVER_ID=localhost
CPAW_DEFAULT_TTL=120
CPAW_LOG_LEVEL=info
CPAW_PUID=1000
CPAW_PGID=1000