Skip to content

Commit 8a0fca2

Browse files
hyperpolymathclaude
andcommitted
fix(container): APP_HOST defaults to 127.0.0.1 (HCG tier-2 E1 prereq)
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 on hyperpolymath/standards#100 — companion to actions #6 (boj-server#130, Cowboy bind in the Elixir path) and #8 (boj-server#131, k8s Service ClusterIP). Together the three layers give defence in depth: Elixir Cowboy binds loopback, Zig adapter binds loopback, k8s Service is internal-only. Changes: - `stapeln.toml` [targets.production]: `APP_HOST = "[::]"` -> `APP_HOST = "127.0.0.1"`. Adds a comment block explaining the Phase E posture and the override path for legacy deployments. - `container/entrypoint.sh` lines 40 + 140: `${APP_HOST:-[::]}` -> `${APP_HOST:-127.0.0.1}`. Adds a comment at the exec line pointing to ADR-0004 + the runbook. - `container/compose.prod.yaml` services.boj-rest.environment: `APP_HOST: "[::]"` -> `APP_HOST: "127.0.0.1"`. Adds an inline comment block. 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 via grep). Leave alone or remove in a hygiene PR; not load-bearing. - Unifying APP_HOST (Zig adapter) and BOJ_BIND_IP (Elixir Cowboy) into one envelope is broader scope; file as a separate issue if the divergence proves annoying in operation. Override path for legacy/standalone deployments without HCG in front: set APP_HOST=0.0.0.0 (IPv4 all-interfaces) or APP_HOST=:: (IPv6 all-interfaces) in the deployment config — the in-repo defaults remain loopback. Refs hyperpolymath/standards#100 Refs hyperpolymath/standards#91 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent fb15cd2 commit 8a0fca2

4 files changed

Lines changed: 33 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,19 @@ All notable changes to Bundle of Joy Server are documented here.
5656
[`hyperpolymath/standards#100`](https://github.com/hyperpolymath/standards/issues/100),
5757
[`#91`](https://github.com/hyperpolymath/standards/issues/91).
5858

59+
- **Container `APP_HOST` default is now `127.0.0.1`** (was: `"[::]"`
60+
IPv6 all-interfaces). Tightens three sites that feed the Zig adapter
61+
binary's `--host` flag: `stapeln.toml [targets.production]`,
62+
`container/entrypoint.sh`, and `container/compose.prod.yaml`. Same
63+
Phase E posture as the Cowboy bind change in the Elixir path: BoJ
64+
binds loopback by default when fronted by `http-capability-gateway`
65+
(HCG tier-2). Legacy/standalone deployments without HCG in front
66+
should override `APP_HOST=0.0.0.0` (IPv4 all-interfaces) or
67+
`APP_HOST=::` (IPv6 all-interfaces) in their deployment config.
68+
Phase E rollout-runbook §1.4 prereq #7. Refs
69+
[`hyperpolymath/standards#100`](https://github.com/hyperpolymath/standards/issues/100),
70+
[`#91`](https://github.com/hyperpolymath/standards/issues/91).
71+
5972
### Added
6073

6174
- **ADR-0014 — cross-cartridge composition safety (RFC)** — frames the

container/compose.prod.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,12 @@ services:
4040
volumes:
4141
- boj-node-data:/data:Z
4242
environment:
43-
# Server binding
44-
APP_HOST: "[::]"
43+
# Server binding — loopback by default per ADR-0004 §1 (BoJ is
44+
# fronted by http-capability-gateway tier-2 and not externally
45+
# routable). Override APP_HOST=0.0.0.0 or APP_HOST=:: for
46+
# legacy/standalone deployments without HCG in front.
47+
# See docs/integration/hcg-tier2-rollout-runbook.md §1.4 prereq #7.
48+
APP_HOST: "127.0.0.1"
4549
APP_PORT: "7700"
4650
APP_DATA_DIR: "/data"
4751
APP_LOG_FORMAT: "json"

container/entrypoint.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ done
3737
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH:+${LD_LIBRARY_PATH}:}${CART_LIBS}"
3838

3939
echo "Starting boj-server..."
40-
echo " Host: ${APP_HOST:-[::]}"
40+
echo " Host: ${APP_HOST:-127.0.0.1}"
4141
echo " Port: ${APP_PORT:-7700}"
4242
echo " Data: ${APP_DATA_DIR:-/data}"
4343
echo " Log: ${APP_LOG_FORMAT:-json}"
@@ -137,4 +137,8 @@ bootstrap_federation &
137137
# Replace the entrypoint shell with the application process so that
138138
# signals are delivered directly and PID 1 is the application.
139139

140-
exec /app/boj-server serve --host "${APP_HOST:-[::]}" --port "${REST_PORT}"
140+
# Default to 127.0.0.1 (loopback) per ADR-0004 §1 — BoJ is fronted by
141+
# http-capability-gateway (HCG tier-2) and is not externally routable
142+
# in canonical deployments. Override APP_HOST for legacy/standalone use.
143+
# See docs/integration/hcg-tier2-rollout-runbook.md §1.4 prereq #7.
144+
exec /app/boj-server serve --host "${APP_HOST:-127.0.0.1}" --port "${REST_PORT}"

stapeln.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,14 @@ env = { LOG_LEVEL = "debug", BOJ_DEV_MODE = "true" }
9797

9898
[targets.production]
9999
layers = ["runtime"]
100-
env = { LOG_LEVEL = "info", APP_HOST = "[::]", APP_PORT = "7700" }
100+
# APP_HOST = "127.0.0.1" (was "[::]") — code-enforces the ADR-0004 §1
101+
# invariant that BoJ's back-side bind is not externally routable in
102+
# deployments fronted by http-capability-gateway (HCG tier-2). See
103+
# docs/integration/hcg-tier2-rollout-runbook.md §1.4 prereq #7.
104+
# Legacy/standalone deployments without HCG in front should override
105+
# APP_HOST=0.0.0.0 (IPv4 all-interfaces) or APP_HOST=:: (IPv6
106+
# all-interfaces) in their deployment configuration.
107+
env = { LOG_LEVEL = "info", APP_HOST = "127.0.0.1", APP_PORT = "7700" }
101108

102109
[targets.test]
103110
layers = ["base", "zig-toolchain", "ffi-build", "adapter-build"]

0 commit comments

Comments
 (0)