clone

a personal forge on plain git: static pages, stacked-diff reviews, signed local ci, repo sites and releases

Run a pinned Caddy 2.11 in the container #7

cat description

Build Caddy v2.11.7 from source like tailcat, rclone and litestream, instead of Debian's 2.6.2, and drop the scenarios' 2.6 workarounds.

commits3oldest firstcombined diff 7 files, +30 -17
revisions2
r2catf1af132what changed since r1
r1cat7f7d40e
discussion0 comments

No comments yet: forge comment 7 adds one.

1/3 Build a pinned Caddy 2.11 for the container

The container installed Debian trixie's Caddy, 2.6.2, from 2022, while
the edge runs Alpine's 2.11. A Go stage now builds Caddy v2.11.7, the
latest patch of the edge's line (the edge's Alpine 3.24 has 2.11.4),
the way tailcat, rclone and litestream are built: CGO_ENABLED=0, go
install at a pinned version, the source checked by the Go checksum
database. It is built as Caddy builds its releases (-trimpath, -s -w),
which keeps the binary at 53M instead of 76M, and with CustomVersion,
since a build of Caddy's own module reports "unknown" otherwise.

Without Debian's package, the Dockerfile makes what it made: the caddy
system user (home /var/lib/caddy, no login shell), added to the git
group as before, and /etc/caddy, where start.sh writes the Caddyfile.
media-types stays, for /etc/mime.types: Go only knows a few content
types itself. libnss3-tools, which the package pulled in for caddy
trust, goes. start.sh, fcgiwrap and the generated Caddyfile are
unchanged; caddy adapt takes the forge's Caddyfile without a warning.

The image is about the same size: 447M of content, from 446M. README.md
says which tools the Dockerfile builds and which Caddy, and
test/container.sh no longer calls the container's Caddy Debian's.
3 files changed, +24 -6
MDockerfile18+++++++++++++++++-
MREADME.md4+++-
Mtest/container.sh8++++----
M Dockerfile +17 -1
@@ -17,21 +17,37 @@ RUN CGO_ENABLED=0 GOBIN=/out go install github.com/rclone/rclone@v1.75.2
1717 FROM golang:1.27.2 AS litestream1818 RUN CGO_ENABLED=0 GOBIN=/out go install github.com/benbjohnson/litestream/cmd/litestream@v0.5.171919 20+# Caddy serves pages, sites and HTTPS clones. Debian's is 2.6, from 2022, and21+# the edge runs 2.11 (Alpine's, deploy/edge), so build a pinned release of22+# the same line, checked the same way. Built as Caddy's own releases are23+# (trimmed paths, no symbol table: a third smaller); a build of Caddy's own24+# module can't read its version, so caddy version is told it (CustomVersion).25+FROM golang:1.27.2 AS caddy26+RUN v=v2.11.7 && CGO_ENABLED=0 GOBIN=/out go install -trimpath \27+ -ldflags "-s -w -X github.com/caddyserver/caddy/v2.CustomVersion=$v" \28+ github.com/caddyserver/caddy/v2/cmd/caddy@$v29+2030 # Node runs the TypeScript sources directly (type stripping). 24 is the LTS2131 # whose WebCrypto has ML-DSA (24.7 and later), so passkeys can be2232 # post-quantum; the forge itself needs 22.18 or later.2333 FROM node:24-trixie-slim2434 35+# Caddy gets the system user Debian's package would make, in the git group36+# to read pages and repos. media-types is /etc/mime.types, the content37+# types Caddy sends for files beyond the few Go knows itself.2538 RUN apt-get update \26- && apt-get install -y --no-install-recommends git openssh-server caddy ca-certificates tini fcgiwrap restic \39+ && apt-get install -y --no-install-recommends git openssh-server ca-certificates tini fcgiwrap restic media-types \2740 && rm -rf /var/lib/apt/lists/* \2841 && adduser --system --group --shell /bin/sh --home /srv/git git \42+ && adduser --system --group --shell /usr/sbin/nologin --home /var/lib/caddy --gecos 'Caddy web server' caddy \2943 && usermod -aG git caddy \44+ && mkdir -p /etc/caddy \3045 && rm -f /etc/ssh/ssh_host_*3146 3247 COPY --from=tailcat /out/tailcat /usr/local/bin/tailcat3348 COPY --from=rclone /out/rclone /usr/local/bin/rclone3449 COPY --from=litestream /out/litestream /usr/local/bin/litestream50+COPY --from=caddy /out/caddy /usr/local/bin/caddy3551 COPY server/container/sshd.conf /etc/ssh/sshd_config.d/forge.conf3652 3753 WORKDIR /opt/forge
M README.md +3 -1
M test/container.sh +4 -4

2/3 Drop the scenarios' workarounds for Caddy 2.6

The container's Caddy is 2.11 now, like the edge's, so the workarounds
2f1c626 added for Debian's 2.6 go: private-web-caddy and
private-web-clone run their Caddy with persist_config off again, so it
saves no config anywhere, and release-caddy adapts deploy/edge/Caddyfile
with whatever Caddy there is instead of skipping it below 2.7. All three
are as they were before that commit.
3 files changed, +3 -9
Mtest/scenarios/private-web-caddy.sh2+-
Mtest/scenarios/private-web-clone.sh2+-
Mtest/scenarios/release-caddy.sh8+-------
M test/scenarios/private-web-caddy.sh +1 -1
M test/scenarios/private-web-clone.sh +1 -1
M test/scenarios/release-caddy.sh +1 -7

3/3 Keep no autosaved Caddy config in the container

start.sh writes /etc/caddy/Caddyfile anew on every boot, and Caddy saved
a copy of the adapted config each time (autosave.json under
/var/lib/caddy/.config, in the container's layer), which nothing loads:
admin is off and Caddy never runs with --resume. persist_config off, which
Caddy 2.6 didn't have and the edge already sets, stops that.
1 file changed, +3 -2
Mserver/container/start.sh5+++--
M server/container/start.sh +3 -2