Commit 5699de0
fix(container): APP_HOST defaults to 127.0.0.1 (HCG tier-2 E1 prereq) (#132)
## Summary
Tightens three sites that feed the Zig adapter binary's `--host` flag in
production deployments, materialising the ADR-0004 §1 invariant that
BoJ's back-side bind is not externally routable when fronted by
`http-capability-gateway` (HCG tier-2).
This is **action item #7** from the [Phase E consumer-side
audit](hyperpolymath/standards#100 (comment)).
The scope expanded during implementation from one site (the audit named
`stapeln.toml`) to three sites — `entrypoint.sh` and `compose.prod.yaml`
had the same `[::]` default that the audit missed. All three sites feed
into the same Zig-adapter `--host` flag, so they need to flip together
for the change to actually take effect at runtime.
Companion PR to **#130** (Cowboy bind tightening in the Elixir path) and
**#131** (k8s Service ClusterIP). Together the three give defence in
depth: Elixir Cowboy binds loopback **AND** Zig adapter binds loopback
**AND** k8s Service is internal-only.
`Refs hyperpolymath/standards#100` (NOT Closes — joint-close is
owner-only).
`Refs hyperpolymath/standards#91`.
## What's in
| File | Change |
|---|---|
| `stapeln.toml` `[targets.production]` | `APP_HOST = "[::]"` →
`APP_HOST = "127.0.0.1"` + comment block. |
| `container/entrypoint.sh` line 40 (log) + line 140 (`exec` invocation)
| `${APP_HOST:-[::]}` → `${APP_HOST:-127.0.0.1}` + comment at exec line.
|
| `container/compose.prod.yaml` `services.boj-rest.environment` |
`APP_HOST: "[::]"` → `APP_HOST: "127.0.0.1"` + comment block. |
| `CHANGELOG.md` | New `### Changed` entry under `[Unreleased]`. |
## Override path for legacy/standalone use
Deployments without HCG in front: set `APP_HOST=0.0.0.0` (IPv4
all-interfaces) or `APP_HOST=::` (IPv6 all-interfaces) in your
deployment config. The in-repo defaults remain loopback.
## Audit-residue follow-ups deliberately NOT in this PR
- `container/Containerfile` line 125: `ENV PHX_HOST=0.0.0.0` is
**vestigial**. Nothing in the codebase reads `PHX_HOST` (verified by
`grep -rn "PHX_HOST\|phx_host" --include="*.ex" ...` returning empty).
Leftover from a former Phoenix incarnation. Safe to leave alone; can be
removed in a hygiene PR if desired.
- Unifying `APP_HOST` (Zig adapter) and `BOJ_BIND_IP` (Elixir Cowboy
from #130) into one envelope is broader scope. The divergence exists
because they feed different binaries built by different toolchains. If
it proves annoying in operation, file a separate issue.
## Why DRAFT
Same reason as #131 — this is a behaviour change for anyone running the
stapeln-built production container or `compose.prod.yaml` as-is and
relying on the default `[::]` for external access. Owner gates merge on
confirming no such reliance, or on coordinating with anyone who needs
the migration path (HCG-in-front, or explicit `APP_HOST=0.0.0.0`
override).
## Test plan
- [x] `stapeln.toml` parses as valid TOML (syntax preserved).
- [x] `container/entrypoint.sh` runs through `sh -n` without syntax
error (no syntax change, just literal substitution).
- [x] `container/compose.prod.yaml` parses as valid YAML.
- [ ] CI green — governance / hypatia / a2ml / k9 / dogfooding all pass.
- [ ] Owner: confirm no live deployment depends on `[::]` default; flip
from DRAFT to ready.
- [ ] Post-merge manual: a stapeln-built production container, with no
env override, refuses connections from non-loopback peers.
## Risk
**Low for the codebase, medium for ops.** No Elixir / Zig / Idris2 /
cartridge logic touched; CI should not show any regressions. Ops risk:
anyone whose runbook assumes the container exposes BoJ on all interfaces
by default will need to set `APP_HOST=0.0.0.0` explicitly. Reasonable
default for the Phase E posture; documented override path.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent fb15cd2 commit 5699de0
4 files changed
Lines changed: 33 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
59 | 72 | | |
60 | 73 | | |
61 | 74 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
44 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
45 | 49 | | |
46 | 50 | | |
47 | 51 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
140 | | - | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
101 | 108 | | |
102 | 109 | | |
103 | 110 | | |
| |||
0 commit comments