fix(deploy): recreate Caddy for a changed Caddyfile, as a reload can't see it
All checks were successful
CI / check (push) Successful in 14m59s
CI / deploy (push) Successful in 19s

The deploy reloaded Caddy when deploy/Caddyfile changed, but a reload
reads the file the container sees, and that is the old one: Docker
mounts a single file by its inode, and git writes a changed file anew.
The first deploy of the assistant connector showed it (the container
still had the Caddyfile without the connector's routes). A changed
Caddyfile now recreates the Caddy container, which mounts the new file;
its certificates are kept in their volume, and the instance is away for
a few seconds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MMm7usAo6q9ZZRoPkWjoxi
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
Tizian 「ティツィアーン」 2026-10-10 15:44:46 +02:00
commit 51023469d3
Signed by: raisondetredev
GPG key ID: 07F6FCF405488B64

View file

@ -68,10 +68,13 @@ main() {
docker compose run --rm --no-deps -e role=maintenance server --apply-migrations
docker compose up -d --remove-orphans
# Caddy reads its Caddyfile when it starts, and `up` doesn't restart it for a
# changed file it mounts: a changed one is reloaded in place, without dropping
# connections.
# changed file it mounts. Nor would `caddy reload` see the change: Docker
# mounts a single file by its inode, and git writes a changed file anew, so
# the container keeps the old one (found 2026-10-10). A changed Caddyfile
# therefore recreates the container, which mounts the new file; the
# certificates are in a volume, and the instance is away for seconds.
if ! git diff --quiet "$deployed" "$commit" -- Caddyfile; then
docker compose exec -T caddy caddy reload --config /etc/caddy/Caddyfile
docker compose up -d --force-recreate --no-deps caddy
fi
wait_until_answering
trap - EXIT