Which caddy docker builds to use?
from anytimesoon@piefed.social to selfhosted@lemmy.world on 23 Jun 14:30
https://piefed.social/c/selfhosted/p/2160332/which-caddy-docker-builds-to-use

I’m looking into setting up https for my local services. Everything is currently set up using the official caddy docker image.

I want to use now connect caddy to cloudflare to resolve the DNS 01. It looks like this is possible with a drop in replacement for caddy from either github.com/CaddyBuilds/caddy-cloudflare or github.com/serfriz/caddy-custom-builds

Is anyone here using these builds? Are they reliable? Is there an alternative I havent considered?

#selfhosted

threaded - newest

ryper@lemmy.ca on 23 Jun 15:14 next collapse

You could just build it yourself, there’s not much to it.

Dockerfile:

ARG VERSION=2

FROM caddy:${VERSION}-builder AS builder

RUN xcaddy build \
    --with github.com/caddy-dns/cloudflare

FROM caddy:${VERSION}

COPY --from=builder /usr/bin/caddy /usr/bin/caddy

My Dockerfile is under dockerfile-dns and then in docker-compose.yaml instead of pointing to an image I have:

services:
  caddy:
    build: ./dockerfile-dns

I’m not 100% sure of the right way to update it, but I think I usually use something like docker compose build --pull --no-cache.

hellmo_luciferrari@lemmy.zip on 23 Jun 15:53 next collapse

I have a Dockerifle like that:

ARG CADDY_VERSION=2.11.3
FROM caddy:${CADDY_VERSION}-builder-alpine AS builder

RUN xcaddy build \
    --with github.com/caddy-dns/cloudflare

FROM caddy:${CADDY_VERSION}-alpine

COPY --from=builder /usr/bin/caddy /usr/bin/caddy

and the docker-compose.yml file I use:

services:
  caddy:
    pull_policy: build
    build:
      context: .

And to build new versions I modify the Dockerfile after doing a docker compose down, and then to build the new version I use docker compose up.

anytimesoon@piefed.social on 23 Jun 15:57 next collapse

This is basically the dockerfile these projects provide, so I guess I could do this myself. How do you keep the caddy container up to date? I have tugtainer (something like watchtower) update caddy automatically, but I guess this set up would break that

ryper@lemmy.ca on 23 Jun 16:03 next collapse

I can’t help you with automation. I update my containers manually, whenever I think to do it. Nothing is accessible outside my network so I’m not worried about staying on top of security updates.

irmadlad@lemmy.world on 23 Jun 21:16 collapse

I have tugtainer (something like watchtower) update caddy automatically, but I guess this set up would break that

Does tugtainer (always makes me giggle) have to ability to label containers for exclusion like watchtower does?

anytimesoon@piefed.social on 24 Jun 08:43 collapse

Yup. It’s basically watchtower with a gui

irmadlad@lemmy.world on 24 Jun 15:45 collapse

Well, what I was thinking/spitballing is that you could label your Caddy container, do updates on everything else. That leaves Caddy to administer when you can devote 15/20 minutes to rebuilding the Caddy container by itself. Not the most graceful, automated solution, but…

AzuraTheSpellkissed@lemmy.blahaj.zone on 23 Jun 20:28 collapse

I’m not entirely sure, but I think you can skip the “–no-cache” as it seems to still check for image updates. It helps to speed things up, especially if you check for updates more frequently.

hellmo_luciferrari@lemmy.zip on 23 Jun 15:31 next collapse

I currently build my own Caddy docker container with a Dockerfile using xcaddy and the caddy-builder-alpine image.

xcaddy adds these github.com/caddy-dns/cloudflare github.com/lucaslorentz/caddy-docker-proxy/v2

anytimesoon@piefed.social on 23 Jun 15:59 collapse

That seems like a good option. How do you keep it updated?

hellmo_luciferrari@lemmy.zip on 23 Jun 16:09 collapse

I have a Dockerifle:

ARG CADDY_VERSION=2.11.3
FROM caddy:${CADDY_VERSION}-builder-alpine AS builder

RUN xcaddy build \
    --with github.com/caddy-dns/cloudflare

FROM caddy:${CADDY_VERSION}-alpine

COPY --from=builder /usr/bin/caddy /usr/bin/caddy

and the docker-compose.yml file I have this snippet at the top, of course this isn’t the full file as there are specifics to my usecase in my full yml:

services:
  caddy:
    pull_policy: build
    build:
      context: .

And to build new versions I modify the Dockerfile after doing a docker compose down, and then to build the new version I use docker compose up.``


Though this is outdated for my current setup, as I also use github.com/lucaslorentz/caddy-docker-proxy by adding “–with github.com/lucaslorentz/caddy-docker-proxy/v2” below where I added the Cloudflare repo.

This is so I can use Docker Labels to to automate entries.

AzuraTheSpellkissed@lemmy.blahaj.zone on 23 Jun 20:25 collapse

Note that the (non-windows) caddy and caddy: builder images are all alpine based. The “-alpine” tags point to the same images (as you can tell by the hashes). But some like to be explicit about it 💜.

AzuraTheSpellkissed@lemmy.blahaj.zone on 23 Jun 20:31 next collapse

I asked myself the same question before. If only caddy had an official image with the cloudflare plugin, so we wouldn’t have to build ourselves or trust 3rd party providers. But oh well, if you have any other custom image, you might as well build caddy as well.

surewhynotlem@lemmy.world on 24 Jun 10:48 collapse

There apparently is now

discuss.tchncs.de/comment/26530031

Tagen_AllAss@discuss.tchncs.de on 23 Jun 23:22 next collapse

There is recently an ‘official’ caddy with cloudflare Docker Image

Maintainer is Matthew Holt himself the creator of Caddy github issue reply from mholt

anytimesoon@piefed.social on 24 Jun 08:48 collapse

Holy shit, that’s awesome! Thanks for sharing

Tagen_AllAss@discuss.tchncs.de on 24 Jun 10:45 collapse

One thing to keep in mind is that the release cycle isn’t very clear. Caddy itself is updated frequently, but this Caddy+Cloudflare image appears to be updated independently and was last rebuilt about 3 months ago. That means it may lag behind upstream Caddy releases, so it’s worth checking whether timely updates are important for your use case.

sandwichsaregood@lemmy.world on 24 Jun 04:20 next collapse

I ended up building it myself, which may be the best option if you want to use other plugins. I have it set up in my own Forgejo with a CI configuration to auto build the binary and docker image. Forgejo let’s you also host container images, so I can just pull from the latest build wherever I need it.

stratself@lemdro.id on 24 Jun 05:24 collapse

I custom-build the Caddy container since it is easy to do with xcaddy. It is automated to run every week via Forgejo Actions on a Forgejo repo, and one can pull the latest images from there using Portainer or whatever docker updater software there is.

You can also use any other CI/CD solutions you like as long as it churn out a regularly updated image. Github Actions is another good one if you don’t wanna set up Forgejo.

The caddy-cloudflare image is probably also enough for your use case, assuming they’re regularly updated. But if you like control, CI is one way to go.