diff --git a/examples/README.md b/examples/README.md index 86868d6..416a9f3 100644 --- a/examples/README.md +++ b/examples/README.md @@ -7,6 +7,7 @@ Real-world examples demonstrating compose-farm patterns for multi-host Docker de | Stack | Type | Demonstrates | |---------|------|--------------| | [traefik](traefik/) | Infrastructure | Reverse proxy, Let's Encrypt, file-provider | +| [coredns](coredns/) | Infrastructure | Wildcard DNS for `*.local` domains | | [mealie](mealie/) | Single container | Traefik labels, resource limits, environment vars | | [uptime-kuma](uptime-kuma/) | Single container | Docker socket, user mapping, custom DNS | | [paperless-ngx](paperless-ngx/) | Multi-container | Redis + PostgreSQL + App stack | @@ -53,7 +54,8 @@ labels: - traefik.http.routers.myapp-local.entrypoints=web ``` -> **Note:** `.local` domains require local DNS (e.g., Pi-hole, Technitium) to resolve to your Traefik host. +> **Note:** `.local` domains require local DNS to resolve to your Traefik host. +> The [coredns](coredns/) example provides this - edit `Corefile` to set your Traefik IP. ### Environment Variables @@ -88,22 +90,6 @@ stacks: autokuma: all # Runs on every configured host ``` -### Multi-Container Stacks - -Database-backed apps with multiple services: - -```yaml -services: - redis: - image: redis:7 - db: - image: postgres:16 - app: - depends_on: - - redis - - db -``` - ### AutoKuma Labels (Optional) The autokuma example demonstrates compose-farm's **multi-host feature** - running the same stack on all hosts using the `all` keyword. AutoKuma itself is not part of compose-farm; it's just a good example because it needs to run on every host to monitor local Docker containers. @@ -124,8 +110,8 @@ cd examples # 1. Create the shared network on all hosts compose-farm init-network -# 2. Start Traefik first (the reverse proxy) -compose-farm up traefik +# 2. Start infrastructure (reverse proxy + DNS) +compose-farm up traefik coredns # 3. Start other stacks compose-farm up mealie uptime-kuma diff --git a/examples/compose-farm-state.yaml b/examples/compose-farm-state.yaml index 2291228..d83cb2b 100644 --- a/examples/compose-farm-state.yaml +++ b/examples/compose-farm-state.yaml @@ -3,6 +3,7 @@ deployed: - primary - secondary - local + coredns: primary mealie: secondary paperless-ngx: primary traefik: primary diff --git a/examples/compose-farm.yaml b/examples/compose-farm.yaml index 5183053..d9cc81e 100644 --- a/examples/compose-farm.yaml +++ b/examples/compose-farm.yaml @@ -27,6 +27,7 @@ hosts: stacks: # Infrastructure (runs on primary where Traefik is) traefik: primary + coredns: primary # DNS for *.local resolution # Multi-host stacks (runs on ALL hosts) # AutoKuma monitors Docker containers on each host diff --git a/examples/coredns/.env b/examples/coredns/.env new file mode 100644 index 0000000..4af2efb --- /dev/null +++ b/examples/coredns/.env @@ -0,0 +1,2 @@ +# CoreDNS doesn't need environment variables +# The Traefik IP is configured in the Corefile diff --git a/examples/coredns/Corefile b/examples/coredns/Corefile new file mode 100644 index 0000000..34f669b --- /dev/null +++ b/examples/coredns/Corefile @@ -0,0 +1,22 @@ +# CoreDNS configuration for .local domain resolution +# +# Resolves *.local to the Traefik host IP (where your reverse proxy runs). +# All other queries are forwarded to upstream DNS. + +# Handle .local domains - resolve everything to Traefik's host +local { + template IN A { + answer "{{ .Name }} 60 IN A 192.168.1.10" + } + template IN AAAA { + # Return empty for AAAA to avoid delays on IPv4-only networks + rcode NOERROR + } +} + +# Forward everything else to upstream DNS +. { + forward . 1.1.1.1 8.8.8.8 + cache 300 + errors +} diff --git a/examples/coredns/compose.yaml b/examples/coredns/compose.yaml new file mode 100644 index 0000000..262e5d9 --- /dev/null +++ b/examples/coredns/compose.yaml @@ -0,0 +1,27 @@ +# CoreDNS - DNS server for .local domain resolution +# +# Demonstrates: +# - Wildcard DNS for *.local domains +# - Config file mounting from stack directory +# - UDP/TCP port exposure +# +# This enables all the .local routes in the examples to work. +# Point your devices/router DNS to this server's IP. +name: coredns +services: + coredns: + image: coredns/coredns:latest + container_name: coredns + restart: unless-stopped + networks: + - mynetwork + ports: + - "53:53/udp" + - "53:53/tcp" + volumes: + - ./Corefile:/root/Corefile:ro + command: -conf /root/Corefile + +networks: + mynetwork: + external: true