Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 16, 2025

ATProto PDS requires wildcard DNS (*.pds.tunebridge.media) for user-specific subdomains. Standard HTTP-01 ACME challenges cannot validate wildcard certificates, necessitating DNS-01 challenges via Cloudflare API.

Implementation

Custom Caddy Image

  • Dockerfile.caddy: Multi-stage build with xcaddy integrating github.com/caddy-dns/cloudflare
  • Base images: caddy:2-buildercaddy:2

Automated Publishing

  • .github/workflows/publish-caddy-cloudflare-test.yml: Multi-arch builds (amd64/arm64)
  • Publishes to ${DOCKERHUB_USERNAME}/caddy-cloudflare-test:latest
  • Triggers: push to main/develop, PRs

Configuration

  • Caddyfile: Added DNS-01 challenge block for PDS wildcard domain
    *.{$PDS_HOSTNAME}, {$PDS_HOSTNAME} {
        tls {
            dns cloudflare {file /run/secrets/cloudflare_api_token}
        }
        reverse_proxy pds:3000
    }
  • docker-compose.yml: Updated Caddy service to use custom image, mounts Cloudflare API token as Docker secret
  • setup-secrets.sh: Added cloudflare_api_token.txt to secrets setup script

Documentation

  • docs/CADDY_CLOUDFLARE.md: Cloudflare API token setup (Zone:DNS:Edit), troubleshooting, security considerations
  • README.md: Added documentation link

Security

  • Minimal GitHub Actions permissions (contents: read)

  • No hardcoded credentials

  • Cloudflare token stored as Docker secret (not environment variable) following project pattern

  • Cloudflare token scoped to Zone:DNS:Edit only

  • Secret mounted read-only at /run/secrets/cloudflare_api_token

  • Pinned action versions with SHA256 hashes

  • CodeQL scan: no vulnerabilities

  • Fixes Add Caddy with Cloudflare DNS plugin for PDS wildcard certificates #119

Original prompt

This section details on the original issue you should resolve

<issue_title>Refactor projects to use aspire apphost model with unified startup for dashboard and TuneBridge app</issue_title>
<issue_description>Build a custom Docker image for Caddy that has the Cloudflare DNS plugin integrated. The image should be published with a GitHub Actions workflow.

Requirements:

  • Integrate the Cloudflare DNS plugin into Caddy in a new Docker image.
  • The image should be published at ${{ secrets.DOCKERHUB_USERNAME }}/caddy-cloudflare-test.
  • Create a GitHub Actions workflow for automated Docker image build and publish.
  • Update the repos caddyfile to use the cloudflare dns plugin for the PDS configuration.

Acceptance Criteria:

  • Dockerfile for Caddy with Cloudflare DNS plugin is created and added to the repository.
  • GitHub Actions workflow (.github/workflows/publish-caddy-cloudflare-test.yml) builds the image and pushes it to Docker Hub using the specified path.
  • Documentation is included for usage and automated publishing steps.

Notes:

  • Ensure Cloudflare credentials/secrets are configurable and documented for users.
  • Use best practices for Dockerfile optimization and GitHub Actions security.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits November 16, 2025 12:34
- Create Dockerfile.caddy with Cloudflare DNS plugin support
- Add GitHub Actions workflow for automated image publishing
- Update Caddyfile to use Cloudflare DNS challenge for wildcard certificates
- Update docker-compose.yml to use custom Caddy image
- Add comprehensive documentation for Cloudflare setup
- Update .env.example with Cloudflare API token configuration

Co-authored-by: tsmarvin <[email protected]>
Copilot AI changed the title [WIP] Refactor projects to use aspire apphost model for Docker Add Caddy with Cloudflare DNS plugin for PDS wildcard certificates Nov 16, 2025
Copilot AI requested a review from tsmarvin November 16, 2025 12:38
Copilot finished work on behalf of tsmarvin November 16, 2025 12:38
.env.example Outdated
# Cloudflare API Token for DNS challenges (required for wildcard certificates)
# Get this from: https://dash.cloudflare.com/profile/api-tokens
# Required permissions: Zone:DNS:Edit
CLOUDFLARE_API_TOKEN=
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a secret not in the .env files

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to use Docker secrets instead of environment variables. The Cloudflare API token is now stored in secrets/cloudflare_api_token.txt and mounted as a read-only secret, following the same pattern as other credentials in the project. (commit 3efa601)

@tsmarvin
Copy link
Owner

@copilot back to you

- Remove CLOUDFLARE_API_TOKEN from .env.example
- Add cloudflare_api_token.txt to setup-secrets.sh script
- Update docker-compose.yml to mount Cloudflare token as secret
- Update Caddyfile to read token from file instead of env var
- Update documentation to reflect secrets-based approach

Co-authored-by: tsmarvin <[email protected]>
Copilot AI requested a review from tsmarvin November 17, 2025 04:47
Copilot finished work on behalf of tsmarvin November 17, 2025 04:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants