Skip to content

feat(compose): run the public gateway under a gateway profile, behind your own TLS proxy - #190

Merged
thiras merged 2 commits into
mainfrom
feat/decdn-gateway-compose
Oct 31, 2026
Merged

thiras merged 2 commits into
mainfrom
feat/decdn-gateway-compose

Conversation

@thiras

@thiras thiras commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Summary

Third of three PRs for #176, after #187 and #188. It adds a Compose gateway profile that runs the public gateway behind the operator's own TLS proxy.

Why there is no nginx on Compose:

  • Stock nginx can't bind tcp/80 and tcp/443 as a non-root account on host networking. Tested: bind() … (13: Permission denied) even with cap_add: NET_BIND_SERVICE, because the binary carries no file capability. Caddy's does, which is why Caddy works.
  • root_allowed stays the iroh services only, as AGENTS.md requires.
  • So the profile runs just the gateway on loopback. Its README section lists what the operator's proxy must do and points at the role's nginx site and lego unit as working examples.

compose.yaml: decdn-gateway

  • Runs the node image's decdn CLI on DECDN_IMAGE_DIGEST, so there is no fourth decdn digest to bump.
  • The command is the role's ExecStart:
    • both listeners on loopback: 127.0.0.1:8484, metrics on 127.0.0.1:9094;
    • the wallet named explicitly;
    • stop_signal: SIGINT;
    • runs as the decdn-gateway account.
  • gateway.toml holds the chain addresses and rpc_url = "${DECDN_GATEWAY_RPC_URL}"; the CLI expands it at start. The URL itself lives in the root-only /etc/decdn-gateway/gateway.env, like the node's decdn.env.
  • An unset domain renders a --public-url the gateway refuses.

decdn-compose

  • init gateway --gateway-domain creates:
    • the account and its directories;
    • the password;
    • the gateway's own wallet, via key-gen from the node image without the node's mounts;
    • gateway.toml from the decdn_gateway mirror;
    • the env template.
  • check covers the wallet and password (private, the account's), the env file (root-only), DECDN_GATEWAY_RPC_URL, the domain (not the example) and the image digest.
  • Ports 8484 and 9094 go in the preflight.
  • health asks loopback / and /metrics.
  • backup takes the wallet, password, config, env file and namespace pointers.
  • 7 new unit tests.

Lints

  • compose/tests/*.jq gain the service's keys, mounts, SIGINT, exact command, inline env and the fail-closed domain.
  • lint-compose renders the env template.
  • 9 negative variants in test-scripts.

Alloy

  • The Compose render scrapes the gateway under the gateway profile, and maps its container to decdn-gateway.service.
  • compose/alloy/config.alloy is regenerated.
  • validate.sh gains a node,gateway,alloy runtime case.

Docs: compose/README.md (a section, the profile table, accounts, secrets), .env.example, AGENTS.md, docs/publishers.md, docs/requirements.md.

Test plan

  • End to end in a throwaway docker:27-dind:
    • decdn-compose init gateway --gateway-domain gw.decdn.test generated a real wallet with the v0.3.0 node image's key-gen, and wrote gateway.toml and the env file.
    • After setting the RPC URL, up passed its preflight and started the gateway. health reported ok for / and /metrics, and the gateway answered 200 for the bare host.
    • stop exited 0 on SIGINT, and backup archived the wallet, password, config and env file.
  • make lint-compose, make lint-alloy (seven Compose runtime cases, including node,gateway,alloy), make test-scripts, make lint, and the decdn-compose unit tests (153)
  • CI
  • Copilot review

Closes #176

🤖 Generated with Claude Code

… your own TLS proxy

- compose.yaml: decdn-gateway, the node image's decdn CLI (DECDN_IMAGE_DIGEST, so
  no fourth decdn digest) with the role's command: both listeners on loopback, the
  wallet named, SIGINT stop, as the decdn-gateway account. gateway.toml reads
  rpc_url as ${DECDN_GATEWAY_RPC_URL} (the CLI expands it), the URL itself in the
  root-only gateway.env. No nginx: stock nginx cannot bind 80/443 as non-root on
  the host network, and root_allowed is not extended for it, so TLS and the
  PUT /_pointer limit are the operator's proxy's (README documents both, pointing
  at the role's site and lego unit).
- decdn-compose: the gateway profile (init gateway --gateway-domain: account,
  directories, password, the gateway's own wallet via key-gen without the node's
  mounts, gateway.toml from the decdn_gateway mirror, the env template), its
  problems, ports, health (GET / and /metrics on loopback) and backup (wallet,
  config, env file, pointers). Unit tests.
- compose/tests/*.jq: the service's keys, mounts, SIGINT, exact command, inline
  env and fail-closed domain; lint-compose renders its env template; negative
  variants in test-scripts.
- Alloy's Compose render scrapes it under the gateway profile; compose/alloy/
  config.alloy regenerated.

Closes #176

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 31, 2026 00:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The script generates a new password when an existing keystore’s password file is missing, allowing preflight to pass and the gateway to start with a wallet it cannot unlock.

1 open issue
What changed in this PR

Adds a Compose deployment path for the public gateway, complementing the existing Ansible role and monitoring support. The gateway runs on loopback behind an operator-managed TLS proxy.

Changes:

  • Adds the gateway profile and wrapper support for initialization, validation, health checks, and backups.
  • Connects gateway metrics and logs to Alloy.
  • Extends security checks, regression tests, and operator documentation.
File Description
tests/​scripts-test.sh Adds negative tests for gateway security invariants.
Makefile Includes the gateway environment template in Compose linting.
docs/​requirements.md Documents Compose gateway networking requirements.
docs/​publishers.md Lists the gateway Compose deployment option.
compose/​tests/​test_decdn_compose.py Tests gateway initialization, validation, backups, and scrape selection.
compose/​tests/​invariants.jq Enforces gateway commands, mounts, identity, and shutdown settings.
compose/​tests/​inline-env.jq Restricts inline gateway environment variables.
compose/​tests/​fail-closed.jq Checks that an unset gateway domain produces an invalid URL.
compose/​README.md Documents gateway setup, proxy requirements, and operations.
compose/​decdn-gateway.env.example Adds the RPC URL and logging environment template.
compose/​decdn-compose Implements gateway lifecycle support.
compose/​compose.yaml Defines the hardened, loopback-only gateway service.
compose/​alloy/​config.alloy Adds gateway metric scraping and log processing.
compose/​.env.example Adds gateway account, domain, allowance, and environment settings.
ansible/​tests/​alloy-config/​validate.sh Validates gateway scrape gating and container mapping.
ansible/​tests/​alloy-config/​render.yml Enables gateway support in the Compose Alloy render.
AGENTS.md Documents the new profile and deployment constraints.

Review effort: Balanced

Comment thread compose/decdn-compose Resolved
init gateway generated a new password beside a restored keystore whose own was
missing, so check passed and the gateway could not unlock its wallet (Copilot
review on #190). It now refuses that state and asks for the original password.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block the Compose gateway changes.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@thiras
thiras merged commit 14cc8ba into main Oct 31, 2026
59 checks passed
@thiras
thiras deleted the feat/decdn-gateway-compose branch October 31, 2026 02:04
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

Successfully merging this pull request may close these issues.

Deploy the public gateway: a role + Compose profile, wildcard-TLS proxy with PUT /_pointer rate limits, metrics and alerts

2 participants