@zigordev/stack 1.0.0 → 1.1.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/README.md +25 -22
- package/compose.local.yaml +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -50,12 +50,13 @@ Without the Docker proxy, the ingress and the agent would hold Docker's socket i
|
|
|
50
50
|
|
|
51
51
|
The five containers form one Compose project named `platform`, whichever folder the files are started from. A product starts the same project from its own copy of this package, so a second start changes nothing, and two products share one set of services.
|
|
52
52
|
|
|
53
|
-
| Name | What it is
|
|
54
|
-
| ----------------- |
|
|
55
|
-
| `zigordev` | The network that every app joins. On it, the services answer to their own names
|
|
56
|
-
| `alloy:4318` | Where an app sends its traces and metrics, over OTLP on HTTP. Port 4317 takes the same over gRPC
|
|
57
|
-
| `
|
|
58
|
-
| `
|
|
53
|
+
| Name | What it is |
|
|
54
|
+
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
55
|
+
| `zigordev` | The network that every app joins. On it, the services answer to their own names |
|
|
56
|
+
| `alloy:4318` | Where an app sends its traces and metrics, over OTLP on HTTP. Port 4317 takes the same over gRPC |
|
|
57
|
+
| `127.0.0.1:4318` | The same port, published on the laptop itself, for an app that runs as a process outside a container, such as one started with `pnpm dev`. HTTP only |
|
|
58
|
+
| `mailpit:1025` | Where an app sends its mail on the laptop, over SMTP |
|
|
59
|
+
| `zigordev-docker` | A second network with no way out. Only the Docker proxy, the ingress and the agent are on it |
|
|
59
60
|
|
|
60
61
|
Nothing in the files points at a file on disk. That is on purpose: Compose recreates a container when the path of a mounted file changes, and each product has this package in a folder of its own. So the ingress and the proxy take their settings as variables and flags, and the agent's config travels inside `compose.yaml`, as the variable `ALLOY_CONFIG`. One line of shell writes it to a file in memory before Alloy starts, and Alloy then replaces that shell. A change to the config therefore recreates the agent and nothing else.
|
|
61
62
|
|
|
@@ -96,14 +97,14 @@ A new app needs no entry anywhere. It appears in the list of the App dashboard w
|
|
|
96
97
|
|
|
97
98
|
### Each container is boxed in
|
|
98
99
|
|
|
99
|
-
| Rule
|
|
100
|
-
|
|
|
101
|
-
| An exact image version
|
|
102
|
-
| A health check
|
|
103
|
-
| A memory limit and a CPU limit
|
|
104
|
-
| An init process, no new privileges, no capabilities, at most 30 seconds to stop
|
|
105
|
-
| A user that is not root, and a read-only file system
|
|
106
|
-
| No published port, except port 80 of the ingress, on this laptop itself
|
|
100
|
+
| Rule | Why |
|
|
101
|
+
| ------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------- |
|
|
102
|
+
| An exact image version | The same bytes on every laptop, and Renovate proposes the next |
|
|
103
|
+
| A health check | `up` can wait for it, and the ingress can trust it |
|
|
104
|
+
| A memory limit and a CPU limit | One service cannot starve the others |
|
|
105
|
+
| An init process, no new privileges, no capabilities, at most 30 seconds to stop | A broken service stays inside its box and stops cleanly |
|
|
106
|
+
| A user that is not root, and a read-only file system | A flaw in the service cannot change the service |
|
|
107
|
+
| No published port, except port 80 of the ingress and port 4318 of the agent, both on this laptop itself | Nothing is reachable from the network the laptop is on |
|
|
107
108
|
|
|
108
109
|
`src/compose.test.ts` holds every service to these rules, one by one, and the job `gcx` to all but the health check, which a job that ends does not need. `lgtm` is the one exception to the last-but-one row: it is six programs in one container, which start as root and write to their own folders. It runs on the laptop only.
|
|
109
110
|
|
|
@@ -135,14 +136,15 @@ Traefik warns once at each start that it "can reject some encoded characters in
|
|
|
135
136
|
|
|
136
137
|
Production is built in phase 3. It will start `compose.yaml` with a `compose.production.yaml` of its own.
|
|
137
138
|
|
|
138
|
-
| Thing
|
|
139
|
-
|
|
|
140
|
-
| The three shared services
|
|
141
|
-
| How a request arrives
|
|
142
|
-
|
|
|
143
|
-
|
|
|
144
|
-
|
|
|
145
|
-
| The
|
|
139
|
+
| Thing | On the laptop | In production |
|
|
140
|
+
| -------------------------------------- | -------------------------------------------------------------------- | ----------------------------------------------------------- |
|
|
141
|
+
| The three shared services | From `compose.yaml` | The same file |
|
|
142
|
+
| How a request arrives | Port 80 on the laptop itself, over IPv4 and IPv6 | Through Cloudflare's tunnel, with no published port |
|
|
143
|
+
| How an app outside a container reports | To `127.0.0.1:4318`, the agent's port published on the laptop itself | Every app runs in a container, so the port is not published |
|
|
144
|
+
| Where the agent sends | To `lgtm`, with a made-up name and password that nothing checks | To Grafana Cloud |
|
|
145
|
+
| Grafana and the mail catcher | `lgtm` and `mailpit` | Grafana Cloud and Amazon SES |
|
|
146
|
+
| The ingress's own pages | At `traefik.localhost` | Off |
|
|
147
|
+
| The proxy's group | 0, which owns the socket on Docker Desktop | The group that owns the socket on the host |
|
|
146
148
|
|
|
147
149
|
## How to use it, with one worked example
|
|
148
150
|
|
|
@@ -227,6 +229,7 @@ Every product starts the same project, named `platform`. Two products that hold
|
|
|
227
229
|
| ------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
228
230
|
| `Cannot connect to the Docker daemon` | Docker is not running | Start Docker Desktop |
|
|
229
231
|
| `Bind for 127.0.0.1:80 failed: port is already allocated` | Another program on the laptop holds port 80 | Find it with `lsof -nP -iTCP:80 -sTCP:LISTEN`, and stop it |
|
|
232
|
+
| `Bind for 127.0.0.1:4318 failed: port is already allocated` | Another program on the laptop holds port 4318, often another OpenTelemetry collector | Find it with `lsof -nP -iTCP:4318 -sTCP:LISTEN`, and stop it |
|
|
230
233
|
| `local:up` ends with "not every shared service became healthy" | One container did not pass its health check in 5 minutes | The lines above name it. `docker logs platform-<service>-1` shows why |
|
|
231
234
|
| `zigordev-stack up` says "the dashboard files are missing" | The files in `stack/observability/` are built, not committed | `pnpm build`, which `pnpm local:up` does by itself |
|
|
232
235
|
| `local:up` says the dashboards and the alert rules could not be pushed | gcx could not reach Grafana, or Grafana refused a file | The lines above name the file and the reason. `pnpm exec vitest run observability` checks the files' shape |
|
package/compose.local.yaml
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zigordev/stack",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "The shared services of the zigordev platform for a laptop: the ingress, the telemetry agent, a local Grafana and a mail catcher, as compose files with one command that starts them",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|