The name `example.Caddyfile` is not considered a valid Caddyfile
caddy run --config ./example.Caddyfile
2023/10/22 06:21:11.620 INFO using provided configuration {"config_file": "./example.Caddyfile", "config_adapter": ""}
Error: loading initial config: decoding request body: invalid character '#' looking for beginning of value
But if I simply rename the:
caddy run --config ./Caddyfile.example
Then it works as expected.
It seems like .Caddyfile (or really anything that isn't .json) should be considered a Caddyfile unless some sort of matching logic for some particular adapter says otherwise.
Any file that starts with Caddyfile will automatically be assumed to be a Caddyfile. From our docs:
If it is called something else that doesn't start with "Caddyfile", you will need to specify --adapter caddyfile.
So you can always specify the adapter name if the file name doesn't conform.
That said, I wonder if we should treat any file name that has Caddyfile in it as a Caddyfile... but maybe that's too liberal.
- equals Caddyfile
- Has prefix Caddyfile.
- Has suffix .Caddyfile
OSes and editors expect to know a file by its specific name, suffix, or magic bytes.
the only other file type I know of that started out with using a prefix as its type identifier is .env.xyz, and its definitely more difficult to get editors to recognize it correctly.
Being consistent with decades long tried and true conventions is generally good for machines and users alike.
Docker does this with the Dockerfile though too. And Vagrant has the Vagrantfile. It's not something we invented nor is it uncommon. Docker is practically everywhere.
But yeah, maybe containing the word Caddyfile is good enough, since it would have to be explicitly given as the config file anyway, so I don't foresee many false positives here. We only automatically use files named exactly Caddyfile.
I think .Caddyfile suffix is okay to support. Maybe even .caddyfile.
Case insensitive options would also be good for those that are allergic to the shift key.
Hi @mholt and @francislavoie, I've submitted a pull request to handle this case. Let me know if there are any other conditions you would like to handle for the Caddyfile naming convention.