feat: add Porkbun DNS provider support - #5165
Conversation
Adds Porkbun as a supported DNS provider alongside Cloudflare and AWS Route53, allowing Dokploy to automatically create DNS records for domains managed on Porkbun. - New DnsClient implementation for the Porkbun API v3 - porkbun enum value and config schema (apiKey/secretApiKey) - Drizzle migration for the new DnsProviderType enum value - UI: provider icon, form fields and provider selector entry - Unit tests covering listZones/listRecords/upsertRecord/updateRecord/deleteRecord/testConnection
| const toSubdomain = (name: string, domain: string) => { | ||
| if (name === domain) { | ||
| return ""; | ||
| } | ||
| const suffix = `.${domain}`; | ||
| return name.endsWith(suffix) ? name.slice(0, -suffix.length) : name; | ||
| }; |
There was a problem hiding this comment.
Trailing-dot names bypass conversion
When a user enters an absolute DNS name such as app.example.com. or example.com., toSubdomain returns the entire FQDN instead of the subdomain or empty apex name, causing Porkbun lookups and writes to use an incorrect record name and resulting in a rejected operation, duplicate, or wrongly named record.
| const toSubdomain = (name: string, domain: string) => { | |
| if (name === domain) { | |
| return ""; | |
| } | |
| const suffix = `.${domain}`; | |
| return name.endsWith(suffix) ? name.slice(0, -suffix.length) : name; | |
| }; | |
| const toSubdomain = (name: string, domain: string) => { | |
| const normalizedName = name.endsWith(".") ? name.slice(0, -1) : name; | |
| if (normalizedName === domain) { | |
| return ""; | |
| } | |
| const suffix = `.${domain}`; | |
| return normalizedName.endsWith(suffix) | |
| ? normalizedName.slice(0, -suffix.length) | |
| : normalizedName; | |
| }; |
| const providerLabels = { | ||
| cloudflare: "Cloudflare", | ||
| route53: "AWS Route53", | ||
| porkbun: "Porkbun", |
There was a problem hiding this comment.
Provider list omits Porkbun label
The editor registers the user-facing Porkbun label, but the separate provider-list label map remains unchanged, so configured Porkbun providers render the raw lowercase badge porkbun instead of the consistently capitalized provider name.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
What is this PR about?
Adds Porkbun as a supported DNS provider alongside Cloudflare and AWS Route53. Once connected, Dokploy can list a Porkbun account's domains as zones and automatically create/update/delete the DNS records needed for a domain, the same flow already available for Cloudflare and Route53 (introduced in v0.30.0).
The implementation follows the existing
DnsClientinterface inpackages/server/src/utils/dns/:porkbun.tsimplementslistZones(via/domain/listAll),listRecords,upsertRecord,updateRecord,deleteRecordandtestConnectionagainst the Porkbun API v3 (https://api.porkbun.com/api/json/v3), authenticating withapikey/secretapikeyin the request body.porkbunvalue was added to theDnsProviderTypePostgres enum and aporkbunDnsConfigSchema(apiKey/secretApiKey) was added to the discriminated union indb/schema/dns-provider.ts, together with the Drizzle migration for the enum change.services/dns-provider.ts.Since Porkbun does not have a separate "zone" concept like Cloudflare, each domain in the account is exposed as a zone (
id/name= the domain itself), and record names are translated between Dokploy's fully-qualified format and Porkbun's subdomain-only format internally.Unit tests were added in
apps/dokploy/__test__/dns/porkbun.test.tscovering allDnsClientmethods (including apex-domain handling and error propagation), mirroring the existing Cloudflare/Route53 test suites.Checklist
Before submitting this PR, please make sure that:
canarybranch.Tested locally:
pnpm run typecheck(server + app) andpnpm testfor the DNS suite all pass (42/42 tests, including the 10 new Porkbun tests). Not tested against a live Porkbun account/API key.Issues related (if applicable)
N/A
Screenshots (if applicable)
N/A
Greptile Summary
Adds Porkbun as a DNS provider across persistence, credential handling, API operations, tests, and dashboard configuration.
Confidence Score: 4/5
The trailing-dot name conversion defect should be fixed before merging because valid absolute DNS names can be sent to Porkbun as incorrect subdomains.
Porkbun is otherwise consistently integrated across schemas, migrations, masking, UI, and client registration, but its conversion of user-entered FQDNs does not account for the DNS root dot and the provider list also lacks the new display label.
Files Needing Attention: packages/server/src/utils/dns/porkbun.ts, apps/dokploy/components/dashboard/settings/dns/handle-dns-provider.tsx
Reviews (1): Last reviewed commit: "feat: add Porkbun DNS provider support" | Re-trigger Greptile