# syntax=docker/dockerfile:1 # Caddy with the CrowdSec bouncer (+ AppSec) and rate limiting, built with # xcaddy on the official builder image. Versions come from the workflow. ARG CADDY_VERSION=2.11.9 FROM caddy:${CADDY_VERSION}-builder AS builder ARG CROWDSEC_BOUNCER_VERSION=v0.15.1 ARG RATELIMIT_VERSION=master # The bouncer may need a newer Go than the builder ships; let go fetch it. ENV GOTOOLCHAIN=auto RUN xcaddy build \ --with github.com/hslatman/caddy-crowdsec-bouncer/http@${CROWDSEC_BOUNCER_VERSION} \ --with github.com/hslatman/caddy-crowdsec-bouncer/appsec@${CROWDSEC_BOUNCER_VERSION} \ --with github.com/mholt/caddy-ratelimit@${RATELIMIT_VERSION} FROM caddy:${CADDY_VERSION}-alpine AS final COPY --from=builder /usr/bin/caddy /usr/bin/caddy ARG FINGERPRINT=dev LABEL org.opencontainers.image.source="https://git.thesatelliteoflove.com/phil/caddy-custom" \ org.opencontainers.image.version="${CADDY_VERSION}" \ caddy.custom.fingerprint="${FINGERPRINT}" # CI gate (BuildKit can't `docker run`): built, never pushed. FROM final AS test RUN caddy version && caddy list-modules --versions > /tmp/mods && grep -E 'crowdsec|appsec|rate_limit' /tmp/mods \ && grep -q '^crowdsec' /tmp/mods \ && grep -q '^http.handlers.crowdsec' /tmp/mods \ && grep -q '^http.handlers.appsec' /tmp/mods \ && grep -q '^http.handlers.rate_limit' /tmp/mods COPY test/Caddyfile /tmp/fixture/Caddyfile RUN CROWDSEC_API_KEY=dummy caddy validate --config /tmp/fixture/Caddyfile --adapter caddyfile # The real production Caddyfile, rendered from phil/ansible by the workflow COPY rendered/Caddyfile /tmp/prod/Caddyfile RUN CROWDSEC_API_KEY=dummy caddy validate --config /tmp/prod/Caddyfile --adapter caddyfile