fix(setup): fail early when a bind-mounted config file is missing - #397
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hit in the wild while moving a long-running deployment back onto the stock compose.
The failure
docker-compose.ymlbind-mounts two config files from the repo:caddy/Caddyfileandgo2rtc/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: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
rmdirit 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:
git checkoutto restore itrmdirit and restore, since that's what a user actually has by the time they investigatePlus a troubleshooting entry for anyone who meets the raw Docker error before running setup.
Verification
Exercised all three cases against a scratch tree:
Caddyfileis a stray directoryCaddyfilemissing entirelybash -nclean; confirmed it passes against a full checkout.No Rust touched, so the Rust gate is unaffected.