Skip to content

fix(setup): fail early when a bind-mounted config file is missing - #397

Merged
badbread merged 1 commit into
mainfrom
fix/preflight-missing-bind-mount-files
Jul 26, 2026
Merged

fix(setup): fail early when a bind-mounted config file is missing#397
badbread merged 1 commit into
mainfrom
fix/preflight-missing-bind-mount-files

Conversation

@badbread

Copy link
Copy Markdown
Owner

Hit in the wild while moving a long-running deployment back onto the stock compose.

The failure

docker-compose.yml bind-mounts two config files from the repo: caddy/Caddyfile and go2rtc/go2rtc.yaml. If one is missing, Docker doesn't say so. It silently creates a directory at that path, and the container then dies with:

error mounting ".../caddy/Caddyfile" to rootfs at "/etc/caddy/Caddyfile":
not a directory: Are you trying to mount a directory onto a file

That names the symptom, not the cause. Worse, it leaves the bogus directory behind, so the obvious next step (restore the file, retry) still fails until you rmdir it by hand.

Easy state to reach when a deployment keeps a partial copy of the repo instead of a full checkout — normal when running from prebuilt images and copying only what looks necessary.

Fix

A preflight in setup-env.sh. There's already precedent directly above it: the script prepares the backup directory specifically because "if Docker auto-creates the bind-mount dir it ends up root-owned and the api can't write." Same failure class, extended to the file mounts.

It handles both states:

  • file missing → names the file and the git checkout to restore it
  • path is a stray directory → tells you to rmdir it and restore, since that's what a user actually has by the time they investigate

Plus a troubleshooting entry for anyone who meets the raw Docker error before running setup.

Verification

Exercised all three cases against a scratch tree:

case result
Caddyfile is a stray directory ✅ errors, tells you to rmdir
Caddyfile missing entirely ✅ errors, names the file
both files present ✅ passes

bash -n clean; confirmed it passes against a full checkout.

No Rust touched, so the Rust gate is unaffected.

docker-compose.yml bind-mounts two config FILES from the repo
(caddy/Caddyfile, go2rtc/go2rtc.yaml). When one is missing, Docker does not
report that: it silently creates a DIRECTORY at the path, then the container
dies with

  error mounting ".../caddy/Caddyfile" to rootfs at "/etc/caddy/Caddyfile":
  not a directory: Are you trying to mount a directory onto a file

which names the symptom and not the cause, and leaves a bogus directory
behind that must be removed by hand before a retry can work. Hit in the wild
on a deployment holding a partial copy of the repo, which is an easy state to
end up in when running from prebuilt images.

setup-env.sh already prepares the backup directory for exactly this reason
(Docker auto-creating a bind-mount source, root-owned and unwritable), so
this extends the same guard to the file mounts. It also detects the
already-broken state where a stray directory exists, since that is what a
user actually has by the time they go looking.

Adds a troubleshooting entry for anyone who hits the raw Docker error.

Signed-off-by: badbread <badbread@users.noreply.github.com>
@badbread
badbread merged commit 9009050 into main Jul 26, 2026
8 checks passed
@badbread
badbread deleted the fix/preflight-missing-bind-mount-files branch July 26, 2026 04:05
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