@openreachtech/hora-skills-ort-renchan 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.ja.md +135 -0
- package/README.md +135 -0
- package/dist/skills/hor-agent-loop/SKILL.md +123 -0
- package/dist/skills/hor-agent-loop/references/core.md +485 -0
- package/dist/skills/hor-agent-loop/references/graphql-integration.md +178 -0
- package/dist/skills/hor-agent-loop/references/renchan-job-integration.md +368 -0
- package/dist/skills/hor-agent-loop/references/testing.md +492 -0
- package/dist/skills/hor-ai-agent-structure/SKILL.md +403 -0
- package/dist/skills/hor-ai-agent-structure/references/loop-and-actions.md +100 -0
- package/dist/skills/hor-ai-prompt-document-store/SKILL.md +220 -0
- package/dist/skills/hor-ai-prompt-document-store/references/models-and-composition.md +156 -0
- package/dist/skills/hor-backend-testing/SKILL.md +118 -0
- package/dist/skills/hor-backend-testing/references/placement-and-ordering.md +89 -0
- package/dist/skills/hor-backend-testing/references/purity-and-mocks.md +82 -0
- package/dist/skills/hor-backend-testing/references/running-tests.md +186 -0
- package/dist/skills/hor-bank-id/SKILL.md +91 -0
- package/dist/skills/hor-build-e2e-test-environment/SKILL.md +609 -0
- package/dist/skills/hor-build-e2e-test-environment/references/compose-definition.md +368 -0
- package/dist/skills/hor-build-e2e-test-environment/references/edge-and-proxy.md +287 -0
- package/dist/skills/hor-build-e2e-test-environment/references/environment-and-ports.md +201 -0
- package/dist/skills/hor-build-e2e-test-environment/references/runner-and-lifecycle.md +330 -0
- package/dist/skills/hor-build-e2e-test-environment/references/seed-data.md +145 -0
- package/dist/skills/hor-build-e2e-test-environment/references/windows-runner.md +146 -0
- package/dist/skills/hor-constant-definition/SKILL.md +139 -0
- package/dist/skills/hor-cookie-authentication/SKILL.md +33 -0
- package/dist/skills/hor-cookie-authentication/references/auth-filter.md +55 -0
- package/dist/skills/hor-cookie-authentication/references/cookie-context.md +53 -0
- package/dist/skills/hor-cookie-authentication/references/dev-login-seeder.md +22 -0
- package/dist/skills/hor-cookie-authentication/references/environment.md +64 -0
- package/dist/skills/hor-cookie-authentication/references/error-codes.md +24 -0
- package/dist/skills/hor-cookie-authentication/references/migrations.md +18 -0
- package/dist/skills/hor-cookie-authentication/references/resolvers.md +97 -0
- package/dist/skills/hor-cookie-authentication/references/session-clerk.md +41 -0
- package/dist/skills/hor-cookie-authentication/references/token-models.md +125 -0
- package/dist/skills/hor-database-design/SKILL.md +54 -0
- package/dist/skills/hor-database-design/references/column-types.md +92 -0
- package/dist/skills/hor-database-design/references/datetimes.md +88 -0
- package/dist/skills/hor-database-design/references/master-tables.md +117 -0
- package/dist/skills/hor-database-design/references/normalization.md +40 -0
- package/dist/skills/hor-database-design/references/update-history.md +35 -0
- package/dist/skills/hor-execution-placement-pattern/SKILL.md +216 -0
- package/dist/skills/hor-external-api-client/SKILL.md +99 -0
- package/dist/skills/hor-external-api-client/references/architecture.md +127 -0
- package/dist/skills/hor-external-api-client/references/authorization.md +105 -0
- package/dist/skills/hor-external-api-client/references/capsule.md +130 -0
- package/dist/skills/hor-external-api-client/references/conventions.md +68 -0
- package/dist/skills/hor-external-api-client/references/launcher.md +138 -0
- package/dist/skills/hor-external-api-client/references/payload.md +176 -0
- package/dist/skills/hor-external-api-client/references/sdk-wrapper.md +291 -0
- package/dist/skills/hor-external-api-client/references/testing.md +130 -0
- package/dist/skills/hor-external-api-client/references/usage.md +152 -0
- package/dist/skills/hor-graphql-schema/SKILL.md +360 -0
- package/dist/skills/hor-graphql-server-engine/SKILL.md +356 -0
- package/dist/skills/hor-light-rag/SKILL.md +242 -0
- package/dist/skills/hor-light-rag/references/retrieval-internals.md +143 -0
- package/dist/skills/hor-multi-llm-provider/SKILL.md +288 -0
- package/dist/skills/hor-multi-llm-provider/references/provider-internals.md +153 -0
- package/dist/skills/hor-mutation-resolver/SKILL.md +360 -0
- package/dist/skills/hor-mutation-resolver/references/dependency-injection.md +148 -0
- package/dist/skills/hor-mutation-resolver/references/errors.md +120 -0
- package/dist/skills/hor-mutation-resolver/references/resolve-flow.md +275 -0
- package/dist/skills/hor-mutation-resolver/references/testing.md +125 -0
- package/dist/skills/hor-mutation-resolver/references/transaction.md +197 -0
- package/dist/skills/hor-post-worker/SKILL.md +320 -0
- package/dist/skills/hor-query-resolver/SKILL.md +246 -0
- package/dist/skills/hor-query-resolver/references/anatomy.md +384 -0
- package/dist/skills/hor-query-resolver/references/data-access.md +248 -0
- package/dist/skills/hor-query-resolver/references/errors-and-context.md +172 -0
- package/dist/skills/hor-query-resolver/references/testing.md +241 -0
- package/dist/skills/hor-renchan-job-bullmq/SKILL.md +178 -0
- package/dist/skills/hor-renchan-job-bullmq/references/daemon-and-scheduler.md +182 -0
- package/dist/skills/hor-renchan-job-bullmq/references/engine-and-infra.md +106 -0
- package/dist/skills/hor-renchan-job-bullmq/references/job-triple.md +189 -0
- package/dist/skills/hor-renchan-job-bullmq/references/queues.md +74 -0
- package/dist/skills/hor-renchan-job-bullmq/references/subscriptions.md +113 -0
- package/dist/skills/hor-resolver-share/SKILL.md +262 -0
- package/dist/skills/hor-resolver-validator/SKILL.md +194 -0
- package/dist/skills/hor-resolver-validator/references/inspector-api.md +115 -0
- package/dist/skills/hor-resolver-validator/references/validator-pattern.md +281 -0
- package/dist/skills/hor-restfulapi-architecture/SKILL.md +275 -0
- package/dist/skills/hor-restfulapi-architecture/references/engine-and-context.md +192 -0
- package/dist/skills/hor-restfulapi-architecture/references/renderers.md +204 -0
- package/dist/skills/hor-restfulapi-architecture/references/response-and-flusher.md +118 -0
- package/dist/skills/hor-restfulapi-architecture/references/validation.md +229 -0
- package/dist/skills/hor-security-audit/SKILL.md +110 -0
- package/dist/skills/hor-security-audit/references/application-surface.md +90 -0
- package/dist/skills/hor-security-audit/references/auth-and-transport.md +147 -0
- package/dist/skills/hor-security-audit/references/code-safety.md +74 -0
- package/dist/skills/hor-security-audit/references/dependencies.md +72 -0
- package/dist/skills/hor-security-audit/references/network-and-logging.md +56 -0
- package/dist/skills/hor-security-audit/references/secrets.md +95 -0
- package/dist/skills/hor-sequelize-migration/SKILL.md +336 -0
- package/dist/skills/hor-sequelize-migration/references/alter-table.md +147 -0
- package/dist/skills/hor-sequelize-migration/references/foreign-keys.md +107 -0
- package/dist/skills/hor-sequelize-migration/references/indexes.md +149 -0
- package/dist/skills/hor-sequelize-migration/references/notation.md +215 -0
- package/dist/skills/hor-sequelize-model/SKILL.md +69 -0
- package/dist/skills/hor-sequelize-model/references/associations.md +218 -0
- package/dist/skills/hor-sequelize-model/references/default-methods.md +244 -0
- package/dist/skills/hor-sequelize-model/references/mixins.md +247 -0
- package/dist/skills/hor-sequelize-model/references/notation.md +225 -0
- package/dist/skills/hor-sequelize-model/references/timestamps.md +74 -0
- package/dist/skills/hor-sequelize-seeder/SKILL.md +275 -0
- package/dist/skills/hor-sequelize-seeder/references/development-coverage.md +74 -0
- package/dist/skills/hor-sequelize-seeder/references/directory-structure.md +113 -0
- package/dist/skills/hor-sequelize-seeder/references/id-numbering.md +133 -0
- package/dist/skills/hor-sequelize-seeder/references/naming.md +59 -0
- package/dist/skills/hor-sequelize-seeder/references/notation.md +170 -0
- package/dist/skills/hor-sequelize-subquery/SKILL.md +369 -0
- package/dist/skills/hor-strategy-pattern/SKILL.md +371 -0
- package/dist/skills/hor-stub-api/SKILL.md +330 -0
- package/dist/skills/hor-subscription-resolver/SKILL.md +105 -0
- package/dist/skills/hor-subscription-resolver/references/authentication.md +99 -0
- package/dist/skills/hor-subscription-resolver/references/basic-notation.md +116 -0
- package/dist/skills/hor-subscription-resolver/references/design-philosophy.md +68 -0
- package/dist/skills/hor-type-interface/SKILL.md +200 -0
- package/docs/skills.ja.md +40 -0
- package/docs/skills.md +40 -0
- package/lib/equip/CommandLineArguments.js +178 -0
- package/lib/equip/HoraSkillsCli.js +590 -0
- package/lib/equip/SkillsInstaller.js +443 -0
- package/lib/equip/SkillsManifestFile.js +260 -0
- package/lib/equip/constants/CLI_COMMAND.js +8 -0
- package/lib/equip/hora-skills-ort-renchan.js +8 -0
- package/package.json +51 -0
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
# The compose definition
|
|
2
|
+
|
|
3
|
+
The compose file that brings the E2E stack up, service by service, and the settings the pipeline
|
|
4
|
+
depends on. Referenced from §2 and §4 of [SKILL.md](../SKILL.md).
|
|
5
|
+
|
|
6
|
+
> **One example stack.** Each service fills a *role* you map your project onto
|
|
7
|
+
> ([SKILL.md §1](../SKILL.md)); keep each section's **general rule** and replace the YAML.
|
|
8
|
+
> Service names, volumes, images, environment variables and ports are **illustrative values**,
|
|
9
|
+
> never values to copy.
|
|
10
|
+
|
|
11
|
+
## Reading a service block
|
|
12
|
+
|
|
13
|
+
Whatever component fills a role, the block for it answers the same four questions:
|
|
14
|
+
|
|
15
|
+
| Question | Where the answer shows up | Holds for any component |
|
|
16
|
+
| --- | --- | --- |
|
|
17
|
+
| what does it need to be configured to emit or accept, for the next role to work? | `command:` / `environment:` | yes — a store that feeds change propagation must be told to produce what the propagator reads |
|
|
18
|
+
| does the host need to reach it, and on which port? | `ports:`, always `127.0.0.1`-prefixed | yes — and a service that advertises its own address must publish the port it advertises |
|
|
19
|
+
| how does it say it is ready? | `healthcheck:` | yes — the runner waits on this and nothing else |
|
|
20
|
+
| what is the most memory it may take from the machine? | `mem_limit` | yes — every container gets a hard cap, and the caps are budgeted against the runtime's memory ([§ Memory](#memory-cap-every-container-then-budget-against-the-runtimes-memory)) |
|
|
21
|
+
| what must be inside its image, so the stack starts without network access? | `build:` | yes — plugins, extensions and drivers are baked in, never downloaded at start |
|
|
22
|
+
|
|
23
|
+
## Why a second compose file
|
|
24
|
+
|
|
25
|
+
The development stack is a place to work in; the E2E stack is a place to *operate the product* in.
|
|
26
|
+
They want different things:
|
|
27
|
+
|
|
28
|
+
| | development stack | E2E stack |
|
|
29
|
+
| --- | --- | --- |
|
|
30
|
+
| lifetime | days, kept between sessions | kept between sessions too, but destroyable in one command |
|
|
31
|
+
| ports | the conventional ones | a block of its own **if** the two must run at once |
|
|
32
|
+
| memory | generous, uncapped | every container hard-capped, all caps budgeted to a conservative slice of the runtime's memory ([§ Memory](#memory-cap-every-container-then-budget-against-the-runtimes-memory)) |
|
|
33
|
+
| data | accumulated by hand | loaded once from the seed set, then mutated by the operator |
|
|
34
|
+
| volumes | persistent | persistent **per project**, dropped only by `clean.sh` |
|
|
35
|
+
|
|
36
|
+
Keeping one file for both means every one of those rows becomes a compromise. Keep two, and put the
|
|
37
|
+
E2E one under `e2e/` where its purpose is obvious.
|
|
38
|
+
|
|
39
|
+
## Memory: cap every container, then budget against the runtime's memory
|
|
40
|
+
|
|
41
|
+
The E2E stack is a stack of resident processes — a database, one or two JVM services, a cache, the
|
|
42
|
+
application and its background daemons — that all hold memory for the entire session while no one
|
|
43
|
+
interacts with them. Left uncapped they will grow to whatever the machine has, and on a laptop their
|
|
44
|
+
total pushes the machine into swap or the out-of-memory killer. Two rules keep that from happening,
|
|
45
|
+
and both are requirements.
|
|
46
|
+
|
|
47
|
+
**Every service gets a hard `mem_limit`.** Not a heap flag — a container-level cap. A container the
|
|
48
|
+
compose file does not cap can use everything the runtime has, so a single uncapped service undoes the
|
|
49
|
+
budget no matter how carefully the others are sized. This is the one line that protects the host.
|
|
50
|
+
|
|
51
|
+
**A JVM heap flag is not a memory cap.** `-Xmx512m` bounds the *heap* only; the JVM's off-heap
|
|
52
|
+
buffers, thread stacks, metaspace and the operating system's page cache for the service all sit on
|
|
53
|
+
top, so a JVM service routinely uses **two to three times its heap** in resident memory. Set the heap
|
|
54
|
+
*and* the `mem_limit`, keep the heap at roughly **half** the `mem_limit`, and read the `mem_limit` —
|
|
55
|
+
never the heap — as the number the machine actually has to find. A store with no heap flag at all (a
|
|
56
|
+
relational database, a cache) still gets a `mem_limit`; it simply grows into it via its own buffers
|
|
57
|
+
and the page cache rather than a `-Xmx`.
|
|
58
|
+
|
|
59
|
+
**Budget the caps against the memory the container runtime was given, conservatively, assuming two
|
|
60
|
+
stacks are up at once.** On native Linux that is the machine's memory; on Docker Desktop and WSL2 it
|
|
61
|
+
is the runtime VM's allocation, which is **half the machine by default** — budget against the
|
|
62
|
+
machine there and the caps overflow the VM long before they trouble the host. The
|
|
63
|
+
whole point of the port block and the dedicated project name ([§4](../SKILL.md)) is that this stack
|
|
64
|
+
can run *beside* the developer's own — so size it as if it always does. The rule of thumb:
|
|
65
|
+
|
|
66
|
+
> **The sum of every `mem_limit` in this stack stays around 40% of the memory the container
|
|
67
|
+
> runtime was given.**
|
|
68
|
+
|
|
69
|
+
Two stacks at 40% leave 20% for the operating system, the editor and the browser — the margin that
|
|
70
|
+
keeps the machine responsive instead of swapping. This is deliberately conservative because the
|
|
71
|
+
failure it prevents (the whole machine freezing) costs far more than a service running in a slightly
|
|
72
|
+
tighter heap. On a 16 GB Linux laptop that is a ~6 GB budget for the entire stack. **The same 16 GB
|
|
73
|
+
machine running WSL2 gives the runtime 8 GB by default, so the budget is ~3.2 GB** — read the figure
|
|
74
|
+
the runtime reports (`docker info`), not the one the machine advertises. The example values below sum
|
|
75
|
+
to well under the Linux figure, and are scaled down rather than letting the total drift up.
|
|
76
|
+
|
|
77
|
+
Expressing the cap in compose:
|
|
78
|
+
|
|
79
|
+
```yaml
|
|
80
|
+
services:
|
|
81
|
+
some-service:
|
|
82
|
+
mem_limit: 1g # compose v2 short form — the hard ceiling for this container
|
|
83
|
+
# deploy: # the Swarm-style long form is only honoured with `--compose-file` under
|
|
84
|
+
# resources: # `docker stack deploy`; for `docker compose up` use `mem_limit` above.
|
|
85
|
+
# limits: { memory: 1g }
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
The example stack's roles, sized to fit inside a ~40% budget with generous headroom, and to leave
|
|
89
|
+
room for the developer's own stack beside it:
|
|
90
|
+
|
|
91
|
+
| Role (example component) | `mem_limit` | Heap flag (≈ half) | Note |
|
|
92
|
+
| --- | --- | --- | --- |
|
|
93
|
+
| system of record (MariaDB) | `768m` | — (buffer pool, not a heap) | cap the InnoDB buffer pool below this in `command:` if the default is generous |
|
|
94
|
+
| cache and job queue (Redis) | `256m` | `--maxmemory 192mb` | set `--maxmemory` under the cap so Redis evicts instead of being OOM-killed |
|
|
95
|
+
| event transport (Kafka) | `1g` | `-Xmx512m` | JVM: cap is ~2× heap |
|
|
96
|
+
| change propagation (Kafka Connect) | `768m` | `-Xmx384m` | JVM: cap is ~2× heap |
|
|
97
|
+
| read model (Elasticsearch) | `1g` | `-Xms512m -Xmx512m` | JVM: cap is ~2× heap; the heaviest single service |
|
|
98
|
+
|
|
99
|
+
That sums to ~3.6 GB — inside a 16 GB Linux machine's budget, but **over** the ~3.2 GB a default
|
|
100
|
+
WSL2 VM on that same machine allows, which is exactly the trap: the figure to check is the
|
|
101
|
+
runtime's.
|
|
102
|
+
The point is the **relationship**: pick each `mem_limit` first from what the service tolerates, keep
|
|
103
|
+
each JVM heap near half its cap, and check the total against the runtime's memory budget before
|
|
104
|
+
committing — not the reverse. **General rule:** whatever components fill the roles, every one gets a
|
|
105
|
+
`mem_limit`, JVM ones get a heap near half of it, and the sum is held to the conservative slice above.
|
|
106
|
+
|
|
107
|
+
## Project name and volumes
|
|
108
|
+
|
|
109
|
+
```yaml
|
|
110
|
+
# e2e/docker/compose.yaml
|
|
111
|
+
name: <project>-e2e # NOT the default (the directory name), and NOT the dev project's
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**The file sits under `e2e/docker/`, with everything it references by relative path beside it** —
|
|
115
|
+
the `build:` contexts under `images/`, the init SQL under `initdb/`, any config a service mounts.
|
|
116
|
+
Compose resolves those paths against this file's directory, so keeping them together lets the
|
|
117
|
+
definition move as a unit; the scripts stay at `e2e/` root and pass `-f e2e/docker/compose.yaml`.
|
|
118
|
+
|
|
119
|
+
- **Declare `name:`.** Without it, compose derives the project name from the directory, and two
|
|
120
|
+
compose files that happen to sit in similarly-named directories share containers, network and
|
|
121
|
+
volumes. Sharing volumes with the development stack is the worst case: the run inherits the last
|
|
122
|
+
session's rows, and fixed seed ids collide on insert.
|
|
123
|
+
- **Named volumes persist between runs, and that is the point.** The operator's data has to survive a
|
|
124
|
+
restart, so `down.sh` never touches the volumes; `clean.sh` is the one command that drops them
|
|
125
|
+
([runner-and-lifecycle.md](./runner-and-lifecycle.md)). A re-run also skips the image build and the
|
|
126
|
+
cluster's startup as a side benefit.
|
|
127
|
+
- **`tmpfs` for the data directory is a trade, not a free speed-up.** It makes a store fast and always
|
|
128
|
+
empty — the change log the capture connector reads works there too — but *always empty* now means
|
|
129
|
+
the operator loses their session's work whenever the container restarts. Use it only for a store
|
|
130
|
+
whose contents are genuinely disposable within a session, never for the system of record.
|
|
131
|
+
|
|
132
|
+
## The services
|
|
133
|
+
|
|
134
|
+
Each heading names the **role** first and the component the example fills it with second.
|
|
135
|
+
|
|
136
|
+
### System of record — example: a relational database with a row-format change log
|
|
137
|
+
|
|
138
|
+
```yaml
|
|
139
|
+
services:
|
|
140
|
+
mariadb:
|
|
141
|
+
image: mariadb:11.4 # pin the minor: the binlog format the connector reads must not move
|
|
142
|
+
mem_limit: 768m # hard container cap (§ Memory); keep the buffer pool below it, next line
|
|
143
|
+
command: >
|
|
144
|
+
--log-bin=mysql-bin
|
|
145
|
+
--binlog-format=ROW
|
|
146
|
+
--binlog-row-image=FULL
|
|
147
|
+
--innodb-buffer-pool-size=384M
|
|
148
|
+
--expire-logs-days=1
|
|
149
|
+
--server-id=1
|
|
150
|
+
environment:
|
|
151
|
+
MARIADB_DATABASE: ${DATABASE_NAME}
|
|
152
|
+
MARIADB_ROOT_PASSWORD: ${DATABASE_PASSWORD}
|
|
153
|
+
ports: ['127.0.0.1:13306:3306']
|
|
154
|
+
volumes:
|
|
155
|
+
- 'e2e-db-data:/var/lib/mysql'
|
|
156
|
+
# e2e/docker/initdb — beside the compose file, because that is what './' resolves against.
|
|
157
|
+
# the account the capture connector reads the log with; runs once, on volume creation
|
|
158
|
+
- './initdb:/docker-entrypoint-initdb.d:ro'
|
|
159
|
+
healthcheck:
|
|
160
|
+
test: ['CMD', 'healthcheck.sh', '--connect', '--innodb_initialized']
|
|
161
|
+
interval: 5s
|
|
162
|
+
retries: 20
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
- **`--binlog-format=ROW` with `--binlog-row-image=FULL` is a requirement, not a preference.**
|
|
166
|
+
Without the full row image a change event does not carry the row's values, and the capture pipeline
|
|
167
|
+
delivers events the consumer cannot act on. A search would then return an empty document rather
|
|
168
|
+
than a missing one. **General rule:** the store must be configured to emit *whatever the change
|
|
169
|
+
propagation mechanism reads* — the equivalent switch is `wal_level=logical` plus a replication slot
|
|
170
|
+
on PostgreSQL, CDC enabled per table on SQL Server, an oplog-backed replica set for change streams,
|
|
171
|
+
and nothing at all where propagation is an outbox table the application writes itself.
|
|
172
|
+
- **Pin the minor version.** A floating major tag can move the change-log format under the propagator
|
|
173
|
+
on a rebuild, breaking the pipeline for a reason that is not in the repository.
|
|
174
|
+
- **The initdb directory runs once, when the volume is created.** Since the volume now survives
|
|
175
|
+
every `down.sh`, a changed SQL file there is applied only after someone runs `clean.sh`, never on
|
|
176
|
+
the next `up.sh`. Say so wherever these files are edited, because the symptom (a missing account,
|
|
177
|
+
an ungranted privilege) looks nothing like its cause.
|
|
178
|
+
- **Short log expiry** (`--expire-logs-days=1`) — this environment has no reason to keep a week of
|
|
179
|
+
change log.
|
|
180
|
+
- **`mem_limit` with the buffer pool sized under it.** The container cap alone stops the database
|
|
181
|
+
from taking the machine, but a database left to size its own buffer pool from *total* RAM will
|
|
182
|
+
size itself for the host, not the cap, and then keep hitting that limit — so set
|
|
183
|
+
`--innodb-buffer-pool-size` (the equivalent for another engine: `shared_buffers`, the cache size)
|
|
184
|
+
to a value comfortably below the `mem_limit`. **General rule:** a store that auto-sizes its cache
|
|
185
|
+
from host memory must be told the smaller figure explicitly, or the cap and the store disagree
|
|
186
|
+
about how much memory exists (§ Memory).
|
|
187
|
+
|
|
188
|
+
### Cache and job queue — example: Redis
|
|
189
|
+
|
|
190
|
+
```yaml
|
|
191
|
+
redis:
|
|
192
|
+
image: redis:7-alpine
|
|
193
|
+
mem_limit: 256m # hard container cap (§ Memory)
|
|
194
|
+
# --maxmemory sits under the cap so Redis evicts rather than being OOM-killed at the cap
|
|
195
|
+
command: ['redis-server', '--save', '', '--appendonly', 'no', '--maxmemory', '192mb', '--maxmemory-policy', 'allkeys-lru']
|
|
196
|
+
ports: ['127.0.0.1:16379:6379']
|
|
197
|
+
healthcheck:
|
|
198
|
+
test: ['CMD', 'redis-cli', 'ping']
|
|
199
|
+
interval: 5s
|
|
200
|
+
retries: 20
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
- **Persistence off** (`--save '' --appendonly no`) — the one store that is allowed to forget.
|
|
204
|
+
Queued jobs are work *in flight*, not the operator's data: the durable state lives in the system of
|
|
205
|
+
record, and a job whose row is still there can be re-triggered. Keeping them across a restart mostly
|
|
206
|
+
means a worker waking up to process a job whose context has moved on. **General rule:** the roles
|
|
207
|
+
that must survive a restart are the ones holding authored state; the queue is not one of them, so
|
|
208
|
+
turn its durability off rather than reasoning about stale jobs later.
|
|
209
|
+
- **`--maxmemory` set below the `mem_limit`, with an eviction policy.** Reach the `mem_limit` and the
|
|
210
|
+
container is OOM-killed outright; reach `--maxmemory` first and the cache evicts a key instead — a
|
|
211
|
+
graceful degradation rather than a dead service. Keep `--maxmemory` a margin under the cap so the
|
|
212
|
+
cache stays inside the container ceiling (§ Memory).
|
|
213
|
+
|
|
214
|
+
### Event transport — example: Kafka in single-node mode
|
|
215
|
+
|
|
216
|
+
```yaml
|
|
217
|
+
kafka:
|
|
218
|
+
image: <kraft-mode-kafka-image>
|
|
219
|
+
mem_limit: 1g # hard container cap (§ Memory); heap below is ~half of it
|
|
220
|
+
environment:
|
|
221
|
+
KAFKA_HEAP_OPTS: '-Xms512m -Xmx512m' # heap ≈ half the cap; JVM overhead lives in the rest
|
|
222
|
+
KAFKA_CFG_NODE_ID: '0'
|
|
223
|
+
KAFKA_CFG_PROCESS_ROLES: controller,broker
|
|
224
|
+
KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: 0@kafka:9093
|
|
225
|
+
# two ways in: Connect is a container and reaches the broker by service name; the test
|
|
226
|
+
# runner is on the host and reaches it through the published port
|
|
227
|
+
KAFKA_CFG_LISTENERS: INTERNAL://:9092,EXTERNAL://:19092,CONTROLLER://:9093
|
|
228
|
+
KAFKA_CFG_ADVERTISED_LISTENERS: INTERNAL://kafka:9092,EXTERNAL://localhost:19092
|
|
229
|
+
KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: INTERNAL:PLAINTEXT,EXTERNAL:PLAINTEXT,CONTROLLER:PLAINTEXT
|
|
230
|
+
KAFKA_CFG_INTER_BROKER_LISTENER_NAME: INTERNAL
|
|
231
|
+
KAFKA_CFG_CONTROLLER_LISTENER_NAMES: CONTROLLER
|
|
232
|
+
KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE: 'false'
|
|
233
|
+
ports: ['127.0.0.1:19092:19092'] # host port == the EXTERNAL listener port
|
|
234
|
+
healthcheck:
|
|
235
|
+
test: ['CMD-SHELL', 'kafka-topics.sh --bootstrap-server localhost:9092 --list']
|
|
236
|
+
interval: 5s
|
|
237
|
+
retries: 30
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
- **The published port must equal the external listener's port.** A broker answers the initial
|
|
241
|
+
connection with cluster metadata containing its *advertised* address, and the client then
|
|
242
|
+
reconnects to that. Map `127.0.0.1:19092:29092` while advertising `localhost:29092` and the client
|
|
243
|
+
connects, is told to go to `29092`, finds nothing there, and every produce and consume fails —
|
|
244
|
+
after a connection that looked fine. Change the listener port and the advertised port together,
|
|
245
|
+
and publish that same number. **General rule:** this applies to every component that answers with
|
|
246
|
+
its own address, not just to this broker — a clustered queue redirecting to a node name, a replica
|
|
247
|
+
set naming its members, a cluster publishing a `publish_address`. Find where the component states
|
|
248
|
+
its own address and make that the address the host can reach.
|
|
249
|
+
- **Two listeners because there are two kinds of client.** One listener can advertise only one
|
|
250
|
+
address; a container client needs the service name, the host runner needs `localhost`. Any
|
|
251
|
+
component reached from both sides has the same two-audience problem, however it is configured.
|
|
252
|
+
- **`KAFKA_CFG_CONTROLLER_LISTENER_NAMES` is required whenever `controller` is a role** — without it
|
|
253
|
+
the entrypoint aborts before the broker starts, because it cannot tell which listener the quorum
|
|
254
|
+
speaks on.
|
|
255
|
+
- **Leave auto-creation off.** A topic the broker invents gets one partition, and **a partition
|
|
256
|
+
count cannot be reduced afterwards** — so a single accidental produce before the create step
|
|
257
|
+
permanently changes the topic's ordering guarantees. The runner creates topics explicitly.
|
|
258
|
+
**General rule:** wherever the transport can invent a channel on first use, turn that off and
|
|
259
|
+
create the channels in the runner, because an invented channel gets defaults you cannot take back.
|
|
260
|
+
- **Heap set to about half the `mem_limit`.** The broker is a JVM, so its `mem_limit` has to cover the
|
|
261
|
+
heap *plus* the off-heap buffers and page cache it uses to move messages — set `KAFKA_HEAP_OPTS`
|
|
262
|
+
near half the cap and let the rest absorb that overhead, rather than sizing the heap to the whole
|
|
263
|
+
container and being OOM-killed under load (§ Memory).
|
|
264
|
+
|
|
265
|
+
### Change propagation — example: a CDC connector in Kafka Connect
|
|
266
|
+
|
|
267
|
+
```yaml
|
|
268
|
+
kafka-connect:
|
|
269
|
+
build: ./images/connect # the capture connector plugin, baked in
|
|
270
|
+
mem_limit: 768m # hard container cap (§ Memory); heap below is ~half of it
|
|
271
|
+
depends_on:
|
|
272
|
+
kafka: { condition: service_started }
|
|
273
|
+
mariadb: { condition: service_healthy }
|
|
274
|
+
environment:
|
|
275
|
+
KAFKA_HEAP_OPTS: '-Xms384m -Xmx384m' # heap ≈ half the cap
|
|
276
|
+
BOOTSTRAP_SERVERS: kafka:9092 # in-network, not the published port
|
|
277
|
+
GROUP_ID: <project>-e2e-connect
|
|
278
|
+
CONNECT_REST_ADVERTISED_HOST_NAME: kafka-connect
|
|
279
|
+
CONFIG_STORAGE_TOPIC: _connect_configs
|
|
280
|
+
OFFSET_STORAGE_TOPIC: _connect_offsets
|
|
281
|
+
STATUS_STORAGE_TOPIC: _connect_status
|
|
282
|
+
KEY_CONVERTER_SCHEMAS_ENABLE: 'false'
|
|
283
|
+
VALUE_CONVERTER_SCHEMAS_ENABLE: 'false'
|
|
284
|
+
ports: ['127.0.0.1:18083:8083'] # only because the runner registers the connector over it
|
|
285
|
+
healthcheck:
|
|
286
|
+
test: ['CMD-SHELL', 'curl -sf http://localhost:8083/connectors']
|
|
287
|
+
interval: 5s
|
|
288
|
+
retries: 40
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
- **The plugin is baked into an image, not downloaded at start.** A start-time download makes the
|
|
292
|
+
stack need the network and fail differently on a slow day, and where outbound access is restricted
|
|
293
|
+
it does not work at all.
|
|
294
|
+
- **Its own storage topics per project.** Connector configuration and offsets live in Kafka, so two
|
|
295
|
+
stacks sharing them means one registers a connector the other did not ask for. A distinct
|
|
296
|
+
`GROUP_ID` (and separate broker, as here) keeps them apart. **General rule:** wherever the
|
|
297
|
+
propagation mechanism keeps its own state — replication slot, offset table, cursor file,
|
|
298
|
+
subscription name — that state needs a name of its own per stack, or the two stacks interfere with
|
|
299
|
+
each other.
|
|
300
|
+
- **The connector registration API is published only because the runner is on the host.** It takes
|
|
301
|
+
no authentication — the `127.0.0.1` prefix keeps it off the network.
|
|
302
|
+
- **A propagator that is not a service at all needs no block here.** An outbox poller or a dual-write
|
|
303
|
+
path lives inside the application, so it is started as one of the background processes instead
|
|
304
|
+
([runner-and-lifecycle.md](./runner-and-lifecycle.md)) — and the ordering constraint (propagation
|
|
305
|
+
registered after the transport's channels and after the master rows) is unchanged.
|
|
306
|
+
|
|
307
|
+
### Read model — example: a search cluster with an analyzer plugin
|
|
308
|
+
|
|
309
|
+
```yaml
|
|
310
|
+
elasticsearch:
|
|
311
|
+
build: ./images/search # the analyzer plugin the application relies on, baked in
|
|
312
|
+
mem_limit: 1g # hard container cap (§ Memory); heap below is ~half of it
|
|
313
|
+
environment:
|
|
314
|
+
discovery.type: single-node
|
|
315
|
+
# heap ≈ half the mem_limit — the rest is JVM off-heap, Lucene buffers and page cache
|
|
316
|
+
ES_JAVA_OPTS: '-Xms512m -Xmx512m' # a fixture, not a workload; NOT the container's total
|
|
317
|
+
xpack.security.enabled: 'true'
|
|
318
|
+
ELASTIC_PASSWORD: ${ELASTICSEARCH_PASSWORD}
|
|
319
|
+
ports: ['127.0.0.1:19200:9200']
|
|
320
|
+
healthcheck:
|
|
321
|
+
test: ['CMD-SHELL', 'curl -sf -u elastic:$$ELASTIC_PASSWORD http://localhost:9200/_cluster/health']
|
|
322
|
+
interval: 5s
|
|
323
|
+
retries: 40
|
|
324
|
+
volumes: ['e2e-search-data:/usr/share/elasticsearch/data']
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
- **A much smaller heap than the development stack, and a `mem_limit` on top of it.** The E2E stack
|
|
328
|
+
must be able to run *beside* the development one; a multi-gigabyte heap on both makes a developer
|
|
329
|
+
stop bringing it up. The heap flag is only half the story: it bounds the JVM heap, but Lucene's
|
|
330
|
+
off-heap buffers and the OS page cache push the container's real footprint to roughly double it,
|
|
331
|
+
so the search node is the heaviest single service and the one whose `mem_limit` — set to about
|
|
332
|
+
twice the heap — matters most to the budget (§ Memory).
|
|
333
|
+
- **Leave authentication on.** Turning it off here means the credential path is never exercised,
|
|
334
|
+
and the first environment that has it enabled is the one that breaks.
|
|
335
|
+
- **The analyzer plugin is baked in for the same reason as the connector plugin** — no network at
|
|
336
|
+
start, so the stack also comes up where outbound access is restricted. The same holds for any
|
|
337
|
+
extension the read model needs (a database extension for a materialized view, a tokenizer
|
|
338
|
+
dictionary, a language pack).
|
|
339
|
+
- **This is the slowest service to become healthy.** Give its health wait the longest retry budget.
|
|
340
|
+
- **A read model that is not a separate service still exists as a step.** A materialized view or a
|
|
341
|
+
denormalized table lives in the system of record, so it has no block here — but it still needs
|
|
342
|
+
creating before anything writes to it, a name of its own per run, and a backfill after seeding.
|
|
343
|
+
|
|
344
|
+
### Edge — example: nginx in front of the application
|
|
345
|
+
|
|
346
|
+
The service block for the edge, the configuration it mounts, and why it is the last service to
|
|
347
|
+
become healthy are in [edge-and-proxy.md](./edge-and-proxy.md), where the rest of the proxy layer
|
|
348
|
+
lives. Everything in this file still applies to it: a `127.0.0.1`-prefixed published port, a
|
|
349
|
+
`mem_limit` like every other container, and a healthcheck the runner can poll.
|
|
350
|
+
|
|
351
|
+
One caveat specific to it: **the container's healthcheck answers from inside the container's own
|
|
352
|
+
namespace**, so it reports healthy while nothing outside can reach the edge. The runner therefore
|
|
353
|
+
also polls the published port from the host — see
|
|
354
|
+
[the health-wait section](./runner-and-lifecycle.md#waiting-on-health-never-on-sleep).
|
|
355
|
+
|
|
356
|
+
## Healthchecks are the contract
|
|
357
|
+
|
|
358
|
+
Every service declares its own healthcheck, and the runner only ever polls compose for the result
|
|
359
|
+
([runner-and-lifecycle.md](./runner-and-lifecycle.md)). Two reasons:
|
|
360
|
+
|
|
361
|
+
- **The service knows when it is ready; the runner does not.** "The port accepts a connection" is not
|
|
362
|
+
readiness for a database still initializing, or for a cluster that has not elected itself.
|
|
363
|
+
- **`depends_on: condition: service_healthy` composes.** Connect must not start before the database
|
|
364
|
+
is genuinely up, or it registers against a server that then restarts, and the connector lands in a
|
|
365
|
+
failed state that no test explains.
|
|
366
|
+
|
|
367
|
+
Use short intervals (5s) and a generous retry count for a fixture: a fast machine then starts fast,
|
|
368
|
+
and a slow one still starts.
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
# The edge and the proxy layer
|
|
2
|
+
|
|
3
|
+
The reverse proxy the browser actually connects to. How to copy its configuration from production,
|
|
4
|
+
which side of the container boundary it belongs on, and what it can and cannot prove. Referenced
|
|
5
|
+
from §5 of [SKILL.md](../SKILL.md).
|
|
6
|
+
|
|
7
|
+
> **nginx is the example. The edge is the role.** Every rule here is about *the thing in front of
|
|
8
|
+
> the application*. The nginx directives are one way to write it, and the Apache versions are in a
|
|
9
|
+
> table below. Service names, ports and paths are **examples**, not values to copy.
|
|
10
|
+
>
|
|
11
|
+
> **This file applies only where production has an edge.** If it does not, skip all of it and do not
|
|
12
|
+
> add a proxy here — a layer production does not run hides bugs just as effectively as a missing
|
|
13
|
+
> one.
|
|
14
|
+
|
|
15
|
+
## What only the edge can catch
|
|
16
|
+
|
|
17
|
+
Each setting below works fine when the browser talks straight to the application. Each one breaks in
|
|
18
|
+
production. An environment with no edge reports all of them as working.
|
|
19
|
+
|
|
20
|
+
| Setting | Left at its default | What happens in production |
|
|
21
|
+
| --- | --- | --- |
|
|
22
|
+
| `Upgrade` / `Connection` headers | not forwarded | WebSocket and GraphQL subscriptions never connect. They time out with no error |
|
|
23
|
+
| `client_max_body_size` | 1MB | uploads over 1MB fail with 413 |
|
|
24
|
+
| `proxy_buffering` | on | a streamed response arrives all at once at the end, or gets cut off |
|
|
25
|
+
| `proxy_read_timeout` | 60s | a slow request fails with 504 while the application is still working |
|
|
26
|
+
| `X-Forwarded-For` / `-Proto` | unset | every client looks like the proxy, so per-client limits count everyone as one. Links fall back to `http` |
|
|
27
|
+
| trailing `/` on `proxy_pass` | — | the path prefix is dropped or doubled, and a route that works locally returns 404 |
|
|
28
|
+
| `try_files` for a single-page app | unset | a deep link or a reload returns 404. Only clicking through from the first page works |
|
|
29
|
+
| cookie `Secure` / `SameSite` | depends where TLS ends | sign-in looks like it worked, then the session is gone on the next request |
|
|
30
|
+
|
|
31
|
+
The first two reach production most often. Both stay hidden until someone uses that one feature.
|
|
32
|
+
|
|
33
|
+
## Copy the configuration from production
|
|
34
|
+
|
|
35
|
+
**Start with the production file. Do not write a new one.** This layer is worth having because it
|
|
36
|
+
carries production's bugs. A file you write fresh has different bugs, so the edge is there and
|
|
37
|
+
proves nothing.
|
|
38
|
+
|
|
39
|
+
Change three things and nothing else:
|
|
40
|
+
|
|
41
|
+
| Change | Why |
|
|
42
|
+
| --- | --- |
|
|
43
|
+
| Remove TLS termination — `listen 443 ssl`, the certificate paths, the redirect from `:80` | there is no certificate here, and the operator connects over loopback |
|
|
44
|
+
| Point `proxy_pass` at the E2E application | this is the only address that differs |
|
|
45
|
+
| Set `server_name` to `_` | you pick the stack by loopback port, not by host name. Host names would mean editing `/etc/hosts` on every machine |
|
|
46
|
+
|
|
47
|
+
Copy everything else **as it is** — header forwarding, body size, timeouts, buffering, and the
|
|
48
|
+
location blocks in their original order. Any other difference is a bug you will not catch.
|
|
49
|
+
|
|
50
|
+
### When production's edge is a managed one
|
|
51
|
+
|
|
52
|
+
A cloud load balancer, an API gateway or a CDN has no configuration file you can copy. Running a
|
|
53
|
+
local nginx in its place is a rehearsal, not the same thing. Do it anyway — it still catches the
|
|
54
|
+
header, body-size and buffering bugs — but be honest about the gap.
|
|
55
|
+
|
|
56
|
+
| Do this | Not this |
|
|
57
|
+
| --- | --- |
|
|
58
|
+
| List the behaviours the product depends on, and reproduce those | Try to imitate the whole product |
|
|
59
|
+
| Write down which ones you could not reproduce, and why | Leave the difference unrecorded |
|
|
60
|
+
| Hand the rest to the deployment runbook, to check after release | Report the local run as end-to-end proof |
|
|
61
|
+
|
|
62
|
+
The ones worth reproducing are almost always the same four: header forwarding, request body size,
|
|
63
|
+
timeouts and buffering. The ones you usually cannot are the provider's own — WAF rules, request
|
|
64
|
+
signing, edge caching, and how it behaves when it is overloaded.
|
|
65
|
+
|
|
66
|
+
### Write down where the copy came from
|
|
67
|
+
|
|
68
|
+
```nginx
|
|
69
|
+
# derived-from: the deployment runbook's edge configuration chapter
|
|
70
|
+
# derived-at: 2026-08-22
|
|
71
|
+
# deltas: TLS termination removed / upstream repointed to the E2E app / server_name relaxed
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
- **Update `derived-at` and rewrite `deltas` every time the production file changes.** A note
|
|
75
|
+
nobody updated does not tell you this is a copy. It tells you the two files are now different.
|
|
76
|
+
- **Watch how long `deltas` gets.** Two or three lines is a copy. A list that keeps growing means
|
|
77
|
+
the copy is turning into a rewrite. Fix the production side instead — usually by moving whatever
|
|
78
|
+
differs into a variable or an included file that both can use.
|
|
79
|
+
- **Name the production chapter, not a file path.** The runbook lives in the other repository, and
|
|
80
|
+
you cannot know its path from here.
|
|
81
|
+
|
|
82
|
+
## The compose service
|
|
83
|
+
|
|
84
|
+
The edge becomes healthy last. It has nothing to serve until the application answers.
|
|
85
|
+
|
|
86
|
+
```yaml
|
|
87
|
+
edge:
|
|
88
|
+
image: nginx:1.27-alpine
|
|
89
|
+
depends_on:
|
|
90
|
+
app:
|
|
91
|
+
condition: service_healthy
|
|
92
|
+
volumes:
|
|
93
|
+
- ./nginx/e2e.conf:/etc/nginx/conf.d/default.conf:ro
|
|
94
|
+
ports:
|
|
95
|
+
- '127.0.0.1:18080:80'
|
|
96
|
+
mem_limit: 64m
|
|
97
|
+
healthcheck:
|
|
98
|
+
test: ['CMD', 'wget', '-q', '-O', '-', 'http://localhost/healthz']
|
|
99
|
+
interval: 5s
|
|
100
|
+
timeout: 3s
|
|
101
|
+
retries: 12
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
- **Mount the config read-only (`:ro`).** The container never writes it, so say so.
|
|
105
|
+
- **Give it a `mem_limit` like every other service.** A proxy is small, but an uncapped container is
|
|
106
|
+
still uncapped ([§ Memory](./compose-definition.md#memory-cap-every-container-then-budget-against-the-runtimes-memory)).
|
|
107
|
+
- **The container's own healthcheck is not enough.** It only sees the inside of the container. The
|
|
108
|
+
runner also polls `http://127.0.0.1:18080/` from the host, which is the side the operator uses.
|
|
109
|
+
|
|
110
|
+
## The nginx configuration
|
|
111
|
+
|
|
112
|
+
```nginx
|
|
113
|
+
# derived-from: the deployment runbook's edge configuration chapter
|
|
114
|
+
# derived-at: 2026-08-22
|
|
115
|
+
# deltas: TLS termination removed / upstream repointed to the E2E app / server_name relaxed
|
|
116
|
+
|
|
117
|
+
upstream app {
|
|
118
|
+
server app:3000;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
server {
|
|
122
|
+
listen 80;
|
|
123
|
+
server_name _;
|
|
124
|
+
|
|
125
|
+
# copied from production as it is — these values are the whole point
|
|
126
|
+
client_max_body_size 30m;
|
|
127
|
+
proxy_read_timeout 300s;
|
|
128
|
+
|
|
129
|
+
location /healthz {
|
|
130
|
+
access_log off;
|
|
131
|
+
return 200 "ok\n";
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
location / {
|
|
135
|
+
proxy_pass http://app;
|
|
136
|
+
|
|
137
|
+
proxy_http_version 1.1;
|
|
138
|
+
proxy_set_header Host $host;
|
|
139
|
+
proxy_set_header X-Real-IP $remote_addr;
|
|
140
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
141
|
+
proxy_set_header X-Forwarded-Proto $scheme;
|
|
142
|
+
|
|
143
|
+
# WebSocket / subscriptions
|
|
144
|
+
proxy_set_header Upgrade $http_upgrade;
|
|
145
|
+
proxy_set_header Connection $connection_upgrade;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Three things go wrong here more than anything else.
|
|
151
|
+
|
|
152
|
+
- **One `proxy_set_header` inside a `location` throws away all the inherited ones.** Set any header
|
|
153
|
+
in a `location` block and every header from the `server` block is gone. This is how a header
|
|
154
|
+
quietly stops being forwarded on one route while every other route is fine. No unit test can see
|
|
155
|
+
it.
|
|
156
|
+
- **`$connection_upgrade` is a map you define, not a built-in.** Put it in the `http` block:
|
|
157
|
+
`map $http_upgrade $connection_upgrade { default upgrade; '' close; }`. Sending a plain
|
|
158
|
+
`Connection: upgrade` on every request breaks keep-alive for normal ones.
|
|
159
|
+
- **A trailing `/` on `proxy_pass` changes the path.** `proxy_pass http://app;` passes the URI
|
|
160
|
+
through. `proxy_pass http://app/;` strips the matched `location` prefix. Copy whichever one
|
|
161
|
+
production uses.
|
|
162
|
+
|
|
163
|
+
### The same settings in Apache
|
|
164
|
+
|
|
165
|
+
| Purpose | nginx (the default here) | Apache httpd |
|
|
166
|
+
| --- | --- | --- |
|
|
167
|
+
| forward | `proxy_pass` | `ProxyPass` / `ProxyPassReverse` |
|
|
168
|
+
| WebSocket | `proxy_set_header Upgrade` / `Connection` | `RewriteCond` + `ProxyPass ws://` (`mod_proxy_wstunnel`) |
|
|
169
|
+
| request body size | `client_max_body_size` | `LimitRequestBody` |
|
|
170
|
+
| upstream timeout | `proxy_read_timeout` | `ProxyTimeout` |
|
|
171
|
+
| turn off buffering | `proxy_buffering off` | `flushpackets=on` / `proxy-sendchunked` |
|
|
172
|
+
| original client address | `X-Forwarded-For` | `mod_remoteip` (`RemoteIPHeader`) |
|
|
173
|
+
| single-page fallback | `try_files $uri /index.html` | `FallbackResource` |
|
|
174
|
+
| compression | `gzip on` | `mod_deflate` |
|
|
175
|
+
|
|
176
|
+
## Which side of the container boundary
|
|
177
|
+
|
|
178
|
+
**Put the edge and the application on the same side. Both in containers, or neither.**
|
|
179
|
+
|
|
180
|
+
```
|
|
181
|
+
A — the edge is part of what you are checking
|
|
182
|
+
[client container ×N] → [edge container] → [app container]
|
|
183
|
+
one compose network, nothing crosses the boundary,
|
|
184
|
+
and the source addresses are really different
|
|
185
|
+
|
|
186
|
+
B — no edge
|
|
187
|
+
[browser on the host] → [app process on the host]
|
|
188
|
+
nothing tests the proxy layer — write that down and pass the check on
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Shape A also makes the stack portable. With all three in containers the host needs only a container
|
|
192
|
+
runtime, and the stack behaves the same on Linux, macOS and WSL2.
|
|
193
|
+
|
|
194
|
+
### What we measured when the boundary was crossed
|
|
195
|
+
|
|
196
|
+
Someone built a stack with the application on the host and the edge in a container. They measured it
|
|
197
|
+
on **WSL2 with Docker Desktop 29.5.2**. All four routes failed. The application was listening on
|
|
198
|
+
`*:3900`, on every interface, the whole time — so "the application was not listening" explains none
|
|
199
|
+
of it.
|
|
200
|
+
|
|
201
|
+
| Route tried | Result |
|
|
202
|
+
| --- | --- |
|
|
203
|
+
| edge with `network_mode: host` | does not work. On Docker Desktop, "host" means the Docker VM, not WSL2. `proxy_pass 127.0.0.1` never reaches the application |
|
|
204
|
+
| bridge network with a published port | **connects, and is useless as a check.** Requests from three different sources all arrived with `$remote_addr` set to `172.17.0.1`. A per-client rule passes even when the code counts every client as one |
|
|
205
|
+
| host connecting to the container's IP | `EHOSTUNREACH`. WSL2's `eth0` was on `172.17.2.189/20`, which overlaps Docker's `172.17.0.0/16` |
|
|
206
|
+
| container connecting to the application on the host | HTTP 000 on all four of `host.docker.internal`, the default gateway, `192.168.65.2`, and WSL2's own address |
|
|
207
|
+
|
|
208
|
+
**The lesson is not that the machine was strange.** The shape was weak from the start, and this
|
|
209
|
+
machine showed it. The `127.x` aliases they used to separate the sources also collapse on plain
|
|
210
|
+
Linux, because loopback traffic to a published port goes through `docker-proxy`. It only works with
|
|
211
|
+
`userland-proxy=false` *and* non-loopback addresses. Call it a quirk of one machine and someone
|
|
212
|
+
builds the same thing again next time.
|
|
213
|
+
|
|
214
|
+
There is a second reason this shape cannot work here. This skill binds the application to
|
|
215
|
+
`127.0.0.1` only ([§4](../SKILL.md)), which closes the route anyway.
|
|
216
|
+
|
|
217
|
+
### A published port hides who the client is
|
|
218
|
+
|
|
219
|
+
**Moving the application into a container is not enough** if your check depends on who the client
|
|
220
|
+
is. Traffic through a published port gets rewritten to the bridge gateway's address before the edge
|
|
221
|
+
sees it. If you need clients to look different, put the clients inside the compose network too.
|
|
222
|
+
That is why shape A has the client in a container.
|
|
223
|
+
|
|
224
|
+
## Testing the edge on its own
|
|
225
|
+
|
|
226
|
+
You can test the edge's configuration without the application. Put an echo server behind it and read
|
|
227
|
+
the headers it received:
|
|
228
|
+
|
|
229
|
+
```
|
|
230
|
+
[client container ×N] → [edge container] → [echo container]
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
It is smaller than the full stack. It needs no seed data. It never crosses the container boundary.
|
|
234
|
+
|
|
235
|
+
**Here is what it proves and what it does not:**
|
|
236
|
+
|
|
237
|
+
| Question | Who answers it |
|
|
238
|
+
| --- | --- |
|
|
239
|
+
| does the edge add a real client address on the right, without a `location` block throwing away the inherited `proxy_set_header`? | **this test** — and nothing else can |
|
|
240
|
+
| does the application read the right entry, counting from the right? | unit tests, which you already have |
|
|
241
|
+
| do the two actually work together, so the behaviour really is per-client? | **neither one** |
|
|
242
|
+
|
|
243
|
+
The echo server has no rate limiter, no session and no application logic. Nothing here reaches the
|
|
244
|
+
behaviour those headers feed into. **You are joining up two separate tests, not running one test end
|
|
245
|
+
to end.** Write it down that way. To close the gap you need the application on the same side, which
|
|
246
|
+
is shape A.
|
|
247
|
+
|
|
248
|
+
The gap this test *does* close is the dangerous one. A `proxy_set_header` that is in one `location`
|
|
249
|
+
and missing from another cannot be caught by a unit test at all. In production it shows up as one
|
|
250
|
+
route behaving differently from the rest.
|
|
251
|
+
|
|
252
|
+
## How to check it works
|
|
253
|
+
|
|
254
|
+
Treat these as intentions — the exact flags differ per tool. Run them **from the host**, because
|
|
255
|
+
that is the side the operator uses.
|
|
256
|
+
|
|
257
|
+
| What to check | How |
|
|
258
|
+
| --- | --- |
|
|
259
|
+
| the edge is serving | `curl -sS -o /dev/null -w '%{http_code}\n' http://127.0.0.1:18080/` |
|
|
260
|
+
| the path prefix survives | request a nested route, and compare the status with the same route on the application's own port |
|
|
261
|
+
| `Upgrade` is forwarded | open the product's subscription or WebSocket feature in the browser **through the edge** and watch data arrive. A 101 in the access log confirms the handshake |
|
|
262
|
+
| the body limit matches production | upload a file just under the limit and one just over, and look for 413 |
|
|
263
|
+
| streaming is not buffered | request the streaming endpoint and check the first bytes arrive before the response finishes |
|
|
264
|
+
| the forwarded address arrives | look in the application's log for the client's address, not the proxy's |
|
|
265
|
+
|
|
266
|
+
**Do all of these for real.** Reading the configuration tells you what the file says. Only a request
|
|
267
|
+
tells you what the edge does.
|
|
268
|
+
|
|
269
|
+
## When you leave the edge out
|
|
270
|
+
|
|
271
|
+
First, be clear which situation you are in. **If production has no edge, there is nothing to leave
|
|
272
|
+
out** — the role does not exist for this product, and there is nothing to record. This section is
|
|
273
|
+
about the other case: production has one, and you decided not to build it here.
|
|
274
|
+
|
|
275
|
+
That is a fair choice — a demo, a deadline, a machine it will not run on. Making it in silence is
|
|
276
|
+
not. Write this down next to the environment:
|
|
277
|
+
|
|
278
|
+
- **what you measured** — the routes you tried and what each returned, as a table
|
|
279
|
+
- **what you fixed in the product** instead of in the environment
|
|
280
|
+
- **what a person still has to decide**, with the options
|
|
281
|
+
- **the decision, and the date**
|
|
282
|
+
- **who checks it instead** — usually the deployment runbook's post-release chapter
|
|
283
|
+
|
|
284
|
+
The note is there so the next person does not spend a day working it out again on the same machine.
|
|
285
|
+
|
|
286
|
+
**Do not leave a broken edge config and a spec that always fails.** A run that is red every time is
|
|
287
|
+
a run nobody reads, and the failures that matter disappear into it.
|