ARG CADDY_VERSION=2.11.4

FROM caddy:${CADDY_VERSION}-builder-alpine AS builder

RUN xcaddy build \
    --with github.com/caddyserver/cache-handler \
    --with github.com/darkweak/storages/simplefs/caddy \
    --with github.com/pberkel/caddy-storage-redis \
    --with github.com/caddy-dns/rfc2136 \
    --with github.com/jarv/caddy-goatcounter

FROM caddy:${CADDY_VERSION}-alpine AS runner

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

COPY Caddyfile .

CMD [ "/usr/bin/caddy", "run" ]
