caddy, docker, and dnsimple
16 Nov 2024 ⦁ #dev ⦁ #homelab ⦁ #self-hosting
“I’m experimenting wth Caddy as a replacement for Nginx.”
Right now, that’s an aspirational statement, and not entirely factual.
Because, I would need to get Caddy to run properly to actually experiment with it.
Alright, haha – enough sarcasm.
In order for me to get Caddy to run with the following requirement - must have a Caddy docker image that supports DNSimple’s TLS challenge. The stock Caddy docker image you get from Dockerhub does not have all of the DNS providers. As a result, you need to build your own image containing the DNSimple module. How might you do this?
Edit your Dockerfile
.
FROM caddy:builder AS builder
# Set Go environment variables to fetch dependencies directly
ENV GO111MODULE=on
ENV GOPROXY=https://goproxy.io
ENV GOSUMDB=off
RUN xcaddy build --with github.com/caddy-dns/dnsimple
FROM caddy:latest
COPY --from=builder /usr/bin/caddy /usr/bin/caddy
When I attempted to build an image with the above, not containing the ENV
’s
I would run into errors related to the proxies used to fetch the Go libraries.
The ENV
’s above were helpful to get things to work, thanks to the comments
here in a Github issue.
Built with:
docker build -t caddy-with-dnsimple .
Bonus compose.yml
contents:
services:
caddy:
image: caddy-with-dnsimple
container_name: caddy
hostname: caddy
restart: always
volumes:
- ./data/caddy:/data
- ./data/caddy/Caddyfile:/etc/caddy/Caddyfile
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
ports:
- 80:80
- 443:443
And started with docker compose up -d