Heavily inspired by IAreKyleW00t/docker-caddy-cloudflare, the official Caddy Docker image with additional modules added:
- caddy-dns/cloudflare module for DNS-01 ACME validation support with Cloudflare.
docker pull docker.io/emarshal/caddy-custom:latestSee Caddy Releases.
This repository makes some opininiated choices for my particular environment/usage. Suggest reviewing at minimum, the following:
- Included modules. (In
Dockerfile.) - Supported platforms. (In
docker/build-push-actionstep indocker.yaml.)
The following tags are available for the emarshal/caddy-custom image.
latest<version>(eg:2.6.4, including:2.6,2, etc.)
Refer to the official Caddy Docker image and docs for more information on using Caddy.
Create the container as usual and include your CF_API_TOKEN. We can utilizing Caddy's support for Environment varaiables to pass these values into our Caddyfile.
Then set the global acme_dns directive in your Caddyfile
{
acme_dns cloudflare {env.CF_API_TOKEN}
}
See the caddy-dns/cloudflare module and tls directive for advanced usage.
You can generate a Cloudflare API token via the Cloudflare web console using the following steps:
- Login to your Dashboard
- Go to Account Profile > API Tokens
- Click "Create token" (Use the "Create Custom Token" option)
- Grant the following permissions:
Zone > Zone > ReadZone > DNS > Edit
You can build the Docker image locally by doing
docker build -t caddy-custom .