├── .act-event.json ├── .actrc ├── .github ├── dependabot.yml └── workflows │ └── main.yml ├── .gitignore ├── Dockerfile └── README.md /.act-event.json: -------------------------------------------------------------------------------- 1 | { 2 | "act": true 3 | } -------------------------------------------------------------------------------- /.actrc: -------------------------------------------------------------------------------- 1 | -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:act-latest 2 | --container-architecture linux/amd64 3 | -e .act-event.json 4 | --bind -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | # Maintain dependencies for GitHub Actions 4 | - package-ecosystem: "github-actions" 5 | directory: "/" 6 | schedule: 7 | interval: "weekly" 8 | assignees: 9 | - "SlothCroissant" 10 | # Check for docker image updates 11 | - package-ecosystem: "docker" 12 | directory: "/" 13 | schedule: 14 | interval: "daily" 15 | assignees: 16 | - "SlothCroissant" 17 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | # This is a basic workflow to help you get started with Actions 2 | 3 | name: Docker Build & Push 4 | 5 | on: 6 | push: 7 | branches: 8 | - main 9 | workflow_dispatch: # Allows you to run this workflow manually from the Actions tab 10 | 11 | env: 12 | DOCKER_USERNAME: slothcroissant 13 | DOCKER_CONTAINER_NAME: caddy-cloudflaredns 14 | DOCKER_TARGET_PLATFORM: linux/amd64, linux/arm64, linux/arm/v8, linux/arm/v7 15 | 16 | jobs: 17 | build: 18 | runs-on: ubuntu-latest 19 | steps: 20 | - name: Checkout 21 | uses: actions/checkout@v4 22 | if: ${{ !github.event.act }} # skip during local actions testing 23 | with: 24 | fetch-depth: '0' 25 | 26 | - name: Set up QEMU 27 | uses: docker/setup-qemu-action@v3 28 | 29 | - name: Set up Docker Buildx 30 | uses: docker/setup-buildx-action@v3 31 | 32 | - name: Prepare 33 | if: success() 34 | id: prepare 35 | run: | 36 | re="^FROM caddy:([^-]+)" 37 | str=$(cat Dockerfile) 38 | tag=$(if [[ $str =~ $re ]]; then echo ${BASH_REMATCH[1]}; else exit 1; fi) 39 | echo "tag=$tag" >> $GITHUB_OUTPUT 40 | 41 | - name: Login to Docker Hub 42 | uses: docker/login-action@v3 43 | with: 44 | username: ${{ env.DOCKER_USERNAME }} 45 | password: ${{ secrets.DOCKER_PASSWORD }} 46 | 47 | - name: Login to GitHub Container Registry 48 | uses: docker/login-action@v3 49 | with: 50 | registry: ghcr.io 51 | username: ${{ github.actor }} 52 | password: ${{ secrets.GITHUB_TOKEN }} 53 | 54 | - name: Login to Quay Container Registry 55 | uses: docker/login-action@v3 56 | with: 57 | registry: quay.io 58 | username: ${{ env.DOCKER_USERNAME }}+pushbot 59 | password: ${{ secrets.QUAY_TOKEN }} 60 | 61 | - name: Build container and Push 62 | uses: docker/build-push-action@v6 63 | with: 64 | context: . 65 | platforms: ${{ env.DOCKER_TARGET_PLATFORM }} 66 | push: true 67 | tags: | 68 | ${{ env.DOCKER_USERNAME }}/${{ env.DOCKER_CONTAINER_NAME }}:${{ steps.prepare.outputs.tag }} 69 | ${{ env.DOCKER_USERNAME }}/${{ env.DOCKER_CONTAINER_NAME }}:latest 70 | ghcr.io/${{ env.DOCKER_USERNAME }}/${{ env.DOCKER_CONTAINER_NAME }}:${{ steps.prepare.outputs.tag }} 71 | ghcr.io/${{ env.DOCKER_USERNAME }}/${{ env.DOCKER_CONTAINER_NAME }}:latest 72 | quay.io/${{ env.DOCKER_USERNAME }}/${{ env.DOCKER_CONTAINER_NAME }}:${{ steps.prepare.outputs.tag }} 73 | quay.io/${{ env.DOCKER_USERNAME }}/${{ env.DOCKER_CONTAINER_NAME }}:latest 74 | 75 | - name: Create Release 76 | uses: softprops/action-gh-release@v2 77 | with: 78 | tag_name: ${{ steps.prepare.outputs.tag }} 79 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .secrets 2 | .DS_Store -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM caddy:2.10.0-builder AS builder 2 | 3 | RUN xcaddy build \ 4 | --with github.com/caddy-dns/cloudflare 5 | 6 | FROM caddy:2.10.0 7 | 8 | COPY --from=builder /usr/bin/caddy /usr/bin/caddy 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Latest Release][version-image]][version-url] 2 | [![caddy on DockerHub][dockerhub-image]][dockerhub-url] 3 | [![Docker Build][gh-actions-image]][gh-actions-url] 4 | 5 | # caddy-cloudflaredns 6 | 7 | Please see the official [Caddy Docker Image](https://hub.docker.com/_/caddy) for deployment instructions. 8 | 9 | Builds are available at the following Docker repositories: 10 | 11 | * Docker Hub: [docker.io/slothcroissant/caddy-cloudflaredns](https://hub.docker.com/r/slothcroissant/caddy-cloudflaredns) 12 | * GitHub Container Registry: [ghcr.io/slothcroissant/caddy-cloudflaredns](https://ghcr.io/slothcroissant/caddy-cloudflaredns) 13 | * Quay Container Registry: [quay.io/slothcroissant/caddy-cloudflaredns](https://quay.io/repository/slothcroissant/caddy-cloudflaredns) 14 | 15 | Few things to note: 16 | 17 | 1. You should add CLOUDFLARE_EMAIL and CLOUDFLARE_API_TOKEN as environment variables to your `docker run` command. Example: 18 | 19 | ``` 20 | docker run -it --name caddy \ 21 | -p 80:80 \ 22 | -p 443:443 \ 23 | -v caddy_data:/data \ 24 | -v caddy_config:/config \ 25 | -v $PWD/Caddyfile:/etc/caddy/Caddyfile \ 26 | -e CLOUDFLARE_EMAIL=me@example.com \ 27 | -e CLOUDFLARE_API_TOKEN=12345 \ 28 | -e ACME_AGREE=true \ 29 | slothcroissant/caddy-cloudflaredns:latest 30 | ``` 31 | 32 | You can obtain your [Cloudflare API token](https://support.cloudflare.com/hc/en-us/articles/200167836-Managing-API-Tokens-and-Keys) via the Cloudflare Portal. To create a API token with minimal scope, the following steps are needed: 33 | 34 | 1. Log into your dashboard, go to account settings, create API token 35 | 2. grant the following permissions: 36 | 37 | * Zone / Zone / Read 38 | * Zone / DNS / Edit 39 | 40 | 2. You should add the following to your Caddyfile as the [tls directive](https://caddyserver.com/docs/caddyfile/directives/tls#tls). 41 | 42 | ``` 43 | tls {$CLOUDFLARE_EMAIL} { 44 | dns cloudflare {$CLOUDFLARE_API_TOKEN} 45 | } 46 | ``` 47 | 48 | 3. This image now supports tagging! [See available tags here](https://hub.docker.com/r/slothcroissant/caddy-cloudflaredns/tags). To select a specific version of `caddy`, set your [Docker image tag](https://docs.docker.com/engine/reference/run/#imagetag) to the caddy version you'd like to use. 49 | 50 | Example: `slothcroissant/caddy-cloudflaredns:2.4.3` 51 | 52 | [version-image]: https://img.shields.io/github/v/release/SlothCroissant/caddy-cloudflaredns?style=for-the-badge 53 | [version-url]: https://github.com/SlothCroissant/caddy-cloudflaredns/releases 54 | 55 | [gh-actions-image]: https://img.shields.io/github/actions/workflow/status/SlothCroissant/caddy-cloudflaredns/main.yml?style=for-the-badge 56 | [gh-actions-url]: https://github.com/SlothCroissant/caddy-cloudflaredns/actions 57 | 58 | [dockerhub-image]: https://img.shields.io/docker/pulls/slothcroissant/caddy-cloudflaredns?label=DockerHub%20Pulls&style=for-the-badge 59 | [dockerhub-url]: https://hub.docker.com/r/slothcroissant/caddy-cloudflaredns 60 | --------------------------------------------------------------------------------