# syntax=docker/dockerfile:1
# ===== Caddy with the Cloudflare DNS provider -----
# Stock Caddy can't do the ACME DNS-01 challenge with Cloudflare; this adds github.com/caddy-dns/cloudflare.
# DNS-01 means certificates for hostnames that only resolve inside your network (no port 80/443 from the
# internet needed). Versions are pinned; `goose upgrade` brings new pins with a new kit.
# Building needs outbound access to the Go module proxy (proxy.golang.org) once; the result is cached.
ARG CADDY_VERSION=2.11.4
FROM caddy:${CADDY_VERSION}-builder AS builder
ARG CADDY_DNS_CLOUDFLARE=v0.2.4
RUN xcaddy build --with github.com/caddy-dns/cloudflare@${CADDY_DNS_CLOUDFLARE}

FROM caddy:${CADDY_VERSION}
COPY --from=builder /usr/bin/caddy /usr/bin/caddy
RUN caddy list-modules | grep -q '^dns.providers.cloudflare$'
