Trim comments to the non-obvious why
Drop narration, history and restated-code comments across the repo, keep short ones for security boundaries, upstream quirks and ordering constraints, and record the convention in CLAUDE.md. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
+6
-40
@@ -1,37 +1,8 @@
|
||||
# =============================================================================
|
||||
# caddy image — the public edge. Caddy with two plugins, plus this
|
||||
# directory's config, checked while the image is built.
|
||||
#
|
||||
# WHY A CUSTOM BUILD
|
||||
# Stock Caddy has neither of these, and the config needs both:
|
||||
# caddy-dns/cloudflare DNS-01 certificates through the Cloudflare API
|
||||
# (sites/prod.caddy), since the router forwards
|
||||
# nothing to obtain them over HTTP.
|
||||
# mholt/caddy-ratelimit the `rate_limit` directive (the `limit` snippet
|
||||
# in the Caddyfile).
|
||||
# xcaddy compiles them in. The cloudflare plugin is pinned to a release;
|
||||
# caddy-ratelimit has had one tagged release (v0.1.0, 2024) and is pinned
|
||||
# to a commit, so Renovate leaves it alone and it is bumped by hand.
|
||||
#
|
||||
# BASE: caddy:2.11.9, the builder and the runtime from the same release
|
||||
# (the builder's xcaddy builds the CADDY_VERSION its image sets). Both
|
||||
# tags are bumped together. Official images are multi-arch.
|
||||
#
|
||||
# THE CONFIG IS VALIDATED AT BUILD TIME
|
||||
# The last RUN parses and provisions the config with `caddy validate`, for
|
||||
# the production sites and the dev ones, against placeholder values for
|
||||
# every variable the config reads. A config that would not load therefore
|
||||
# fails the image build, and a failed build aborts `docker compose up
|
||||
# --build` BEFORE any container is replaced, so the running edge keeps
|
||||
# serving. `make check-caddy` is the same build. The placeholders exist
|
||||
# only for that RUN; the real values come from the container's
|
||||
# environment (docker-compose.yml).
|
||||
#
|
||||
# NO ENTRYPOINT. The base image's CMD runs
|
||||
# `caddy run --config /etc/caddy/Caddyfile --adapter caddyfile`, which is all
|
||||
# that is needed: Caddy reads the environment itself, and obtains and renews
|
||||
# its own certificates.
|
||||
# =============================================================================
|
||||
# Caddy plus the Cloudflare DNS and rate-limit plugins. caddy-ratelimit is
|
||||
# pinned to a commit (no usable release), so Renovate leaves it; bump by hand.
|
||||
# Builder and runtime tags move together.
|
||||
# The last RUN validates the config for both modes, so a bad config fails the
|
||||
# build before any running container is replaced.
|
||||
FROM caddy:2.11.9-builder AS builder
|
||||
RUN xcaddy build \
|
||||
--with github.com/caddy-dns/[email protected] \
|
||||
@@ -41,13 +12,8 @@ FROM caddy:2.11.9
|
||||
COPY --from=builder /usr/bin/caddy /usr/bin/caddy
|
||||
COPY Caddyfile routes.caddy /etc/caddy/
|
||||
COPY sites/ /etc/caddy/sites/
|
||||
# Mount points (docker-compose.yml). Created so Caddy still starts without
|
||||
# them: the log directory especially, since a log file that cannot be opened
|
||||
# stops the config loading.
|
||||
# A log directory that can't be opened stops the config loading.
|
||||
RUN mkdir -p /var/log/caddy /srv/www /srv/uploads
|
||||
# Validation writes Caddy's data and the payload log, so it is pointed at a
|
||||
# throwaway directory and the log is removed afterwards, leaving the image as
|
||||
# it was.
|
||||
RUN set -e; \
|
||||
for site in prod dev; do \
|
||||
echo "caddy validate (CADDY_SITE=$site)"; \
|
||||
|
||||
Reference in New Issue
Block a user