fix(docker): make compose.caddy.yaml parseable and functional - #29
fix(docker): make compose.caddy.yaml parseable and functional#29jatinsahijwani wants to merge 1 commit into
Conversation
compose.caddy.yaml cannot be parsed by Docker Compose:
failed to parse compose.caddy.yaml: yaml: construct errors:
line 25: mapping key "depends_on" already defined at line 22
Because the file fails to parse, the Caddy TLS overlay cannot be used at
all. There are three defects, plus a fourth that would surface once the
file parses:
1. A duplicate "depends_on" key, which is a hard YAML parse error.
2. An environment variable (LIGHTWALLETD_DOMAIN) listed as a service
under "depends_on", where it has no effect.
3. A bind mount of ./configs/Caddyfile, which does not exist in the
repository. Neither LIGHTWALLETD_DOMAIN nor CADDY_EMAIL is defined in
.env either, so Caddy would start with no usable configuration.
4. The caddy service joins an external "zcash-network", but the services
in compose.yaml use the default project network, so caddy could not
resolve lightwalletd by name.
This change:
- removes the duplicate depends_on and the misplaced variable, keeping a
single "depends_on: [lightwalletd]";
- moves LIGHTWALLETD_DOMAIN into the caddy service environment next to
CADDY_EMAIL so the Caddyfile can read it;
- drops the external network block so caddy shares the default project
network with lightwalletd;
- adds docker/configs/Caddyfile, which terminates TLS and reverse
proxies to lightwalletd gRPC on port 9067 over h2c;
- documents LIGHTWALLETD_DOMAIN and CADDY_EMAIL in docker/.env.
Verified:
- "docker compose -f compose.yaml -f compose.caddy.yaml config" exits 0
- caddy and lightwalletd both resolve on the default project network
- "caddy validate" reports "Valid configuration"
- the same TLS to h2c setup serves a live mainnet lightwalletd endpoint
|
Nice, thank you for the contribution! A few quick suggestions:
|
Problem
docker/compose.caddy.yamlcannot be parsed by Docker Compose:Because the file fails to parse, the Caddy TLS overlay cannot be used at all. Anyone following the workshop to put their node behind TLS hits this immediately.
There are three defects in the file, plus a fourth that would surface as soon as it parses:
depends_onkey (lines 22 and 25). This is a hard YAML parse error, not a last-one-wins merge.- LIGHTWALLETD_DOMAIN=${LIGHTWALLETD_DOMAIN:-localhost}sits insidedepends_on, where it has no effect../configs/Caddyfile, which does not exist in the repository.git ls-filestracks no Caddyfile. NeitherLIGHTWALLETD_DOMAINnorCADDY_EMAILis defined indocker/.env, so even once the file parsed, Caddy would start with no usable configuration.caddyservice joins anexternal: truenetwork namedzcash-network, but the services incompose.yamluse the default project network. Caddy could not resolvelightwalletdby name.Changes
depends_onand the misplaced variable, keeping a singledepends_on: [lightwalletd].LIGHTWALLETD_DOMAINinto the caddy serviceenvironment, next to the existingCADDY_EMAIL, so the Caddyfile can read it.lightwalletd.docker/configs/Caddyfile. It obtains a Let's Encrypt certificate for{$LIGHTWALLETD_DOMAIN}and reverse proxies to lightwalletd gRPC on port9067over h2c. Port 9067 is lightwalletd's--grpc-bind-addrincompose.yaml.LIGHTWALLETD_DOMAINandCADDY_EMAILindocker/.env.Scope is deliberately limited to making this one overlay work.
compose.vps.yaml, which is the Cloudflare and tunnel oriented variant, is untouched.Verification
All three checks pass.
The same TLS to h2c arrangement is also running in practice against mainnet. On a node built from this repository, Caddy obtained a Let's Encrypt certificate and
GetLightdInforeturns correctly through it on port 443:Notes
Operators who want no request logging can add the following inside the site block, which is what the deployment above uses: