caddy-docker-proxy icon indicating copy to clipboard operation
caddy-docker-proxy copied to clipboard

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

Open polarathene opened this issue 3 years ago • 0 comments

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 :+1:

polarathene avatar Nov 05 '22 20:11 polarathene