Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: import ./path/to/file is not relative to Caddyfile #422

Open
polarathene opened this issue Nov 5, 2022 · 0 comments
Open

docs: import ./path/to/file is not relative to Caddyfile #422

polarathene opened this issue Nov 5, 2022 · 0 comments

Comments

@polarathene
Copy link

The official Caddy docs describe that a relative filepath is from the file calling import:

Its contents will replace this line as if that file's contents appeared here to begin with.
If the pattern is a filename or glob, it is always relative to the file the import appears in.

This was not my experience with CDP however.

I assume despite CADDY_DOCKER_CADDYFILE_PATH, CDP is importing this snippet from a different location? I did not see any mention of this gotcha when searching the README for keywords like import, snippets, cwd, working.


I searched the issues and came across this response:

The import paths are relative to the CWD, which inside the container is /srv I believe.
So I recommend using absolute paths instead.

Using absolute paths does work, as does changing working_dir for the CDP container to the directory for CADDY_DOCKER_CADDYFILE_PATH (although I'm not sure if changing that risks breaking something else?).

Upstream Caddy works fine without setting the working_dir despite changing the Caddyfile location with caddy run --config /path/to/Caddyfile.

If using absolute paths for import, any imports within those imported files will be relative to that file though 👍

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

No branches or pull requests

1 participant