Skip to content

Mount Caddy's folder so a deploy's Caddyfile reaches it - #38

Merged
MCCProgrammer merged 1 commit into
mainfrom
fix/caddy-config-mount
Oct 28, 2026
Merged

MCCProgrammer merged 1 commit into
mainfrom
fix/caddy-config-mount

Conversation

@MCCProgrammer

Copy link
Copy Markdown
Owner

The bug

The first ZAP run failed: Permissions-Policy (#36) was in the Caddyfile on the server, but not in the site's answers.

  • The deploy unpacks deploy/ with tar, which replaces Caddyfile with a new file (new inode).
  • Caddy had the file mounted on its own (./Caddyfile:/etc/caddy/Caddyfile). A single-file bind mount stays on the inode it was given, so the container kept seeing the original file.
  • On the server: the host file is inode 570816, while inside Caddy it is still 570815, without the header.
  • So caddy reload in deploy.sh has re-read the first Caddyfile on every deploy. No Caddyfile change has ever reached the site.

The fix

  • deploy/Caddyfile moves to deploy/caddy/Caddyfile, and Caddy mounts the folder (./caddy:/etc/caddy:ro). A folder mount shows the new file, so the reload, which drops no connections, reads it.
  • The CI deploy copies caddy/ instead of Caddyfile.
  • The monitoring job now also runs caddy validate on the Caddyfile, with the Caddy version from compose.yaml.
  • The other files mounted one by one (backup.sh, offsite.sh) are fine: their containers are restarted on each deploy, and a restart mounts the new file.

Checks

  • Reproduced in a Linux Docker (docker:dind), doing what the deploy does (tar, then caddy reload):
    • file mount: the site still answers with the old header;
    • folder mount: it answers with the new one.
  • Docker Desktop on the Mac shows the new file in both cases, which is why the earlier local tests didn't catch this.
  • caddy validate, actionlint and shellcheck pass.

After the merge

Compose recreates the Caddy container, because its mount changed. That means a few seconds without the site. The old /opt/extpulse/Caddyfile stays on the server unused and can be deleted. Once deployed, re-run the ZAP workflow.

The deploy replaces the Caddyfile with a new file, and Caddy saw it through a
single-file bind mount, which stays on the old file: every reload read the first
Caddyfile, so the Permissions-Policy from #36 never reached the site (ZAP's first run
failed on it). Caddy now mounts deploy/caddy/, which shows the new file, and the
monitoring job validates the Caddyfile.
@sonarqubecloud

Copy link
Copy Markdown

@MCCProgrammer
MCCProgrammer merged commit 2a75ef1 into main Oct 28, 2026
10 checks passed
@MCCProgrammer
MCCProgrammer deleted the fix/caddy-config-mount branch October 28, 2026 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant