@zigordev/stack 1.0.0 → 1.2.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 +36 -30
- package/compose.local.yaml +9 -3
- package/compose.yaml +12 -5
- 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,24 +97,26 @@ 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
|
|
104
|
-
|
|
|
105
|
-
|
|
|
106
|
-
|
|
|
100
|
+
| Rule | Why |
|
|
101
|
+
| ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
|
|
102
|
+
| An exact image version and its digest | The same bytes everywhere, and a tag pushed again changes nothing. Renovate proposes the next |
|
|
103
|
+
| A health check | `up` can wait for it, and the ingress can trust it |
|
|
104
|
+
| A restart unless it was stopped | The host restarts at night for updates, and every service comes back by itself |
|
|
105
|
+
| A memory limit and a CPU limit | One service cannot starve the others |
|
|
106
|
+
| An init process, no new privileges, no capabilities, at most 30 seconds to stop | A broken service stays inside its box and stops cleanly |
|
|
107
|
+
| A user that is not root, and a read-only file system | A flaw in the service cannot change the service |
|
|
108
|
+
| 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
109
|
|
|
108
110
|
`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
111
|
|
|
110
|
-
| Service | Memory limit | CPU limit | Used when idle on 2026-11-22
|
|
111
|
-
| -------------- | ------------ | --------- |
|
|
112
|
-
| `traefik` | 128 MiB | 1 | 24 MiB
|
|
113
|
-
| `docker-proxy` | 64 MiB | 0.25 | 11 MiB
|
|
114
|
-
| `alloy` | 256 MiB | 1 | 51 MiB
|
|
115
|
-
| `lgtm` | 2 GiB | 2 | 614 MiB
|
|
116
|
-
| `mailpit` | 128 MiB | 0.5 | 10 MiB
|
|
112
|
+
| Service | Memory limit | CPU limit | Used when idle on 2026-11-22 |
|
|
113
|
+
| -------------- | ------------ | --------- | --------------------------------- |
|
|
114
|
+
| `traefik` | 128 MiB | 1 | 24 MiB |
|
|
115
|
+
| `docker-proxy` | 64 MiB | 0.25 | 11 MiB |
|
|
116
|
+
| `alloy` | 256 MiB | 1 | 51 MiB |
|
|
117
|
+
| `lgtm` | 2 GiB | 2 | 614 MiB |
|
|
118
|
+
| `mailpit` | 128 MiB | 0.5 | 10 MiB |
|
|
119
|
+
| `cloudflared` | 128 MiB | 0.5 | Not measured yet, production only |
|
|
117
120
|
|
|
118
121
|
### The Docker proxy
|
|
119
122
|
|
|
@@ -133,16 +136,18 @@ Traefik warns once at each start that it "can reject some encoded characters in
|
|
|
133
136
|
|
|
134
137
|
### The laptop and production
|
|
135
138
|
|
|
136
|
-
|
|
139
|
+
The host starts `compose.yaml` with `compose.production.yaml`, through the deploy path of platform: every merge to `main` deploys them as the target `platform`. `docs/cloud-first-deploy.md` in platform says how.
|
|
137
140
|
|
|
138
|
-
| Thing
|
|
139
|
-
|
|
|
140
|
-
| The three shared services
|
|
141
|
-
| How a request arrives
|
|
142
|
-
|
|
|
143
|
-
|
|
|
144
|
-
|
|
|
145
|
-
|
|
|
141
|
+
| Thing | On the laptop | In production |
|
|
142
|
+
| -------------------------------------- | -------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
|
|
143
|
+
| The three shared services | From `compose.yaml` | The same file |
|
|
144
|
+
| How a request arrives | Port 80 on the laptop itself, over IPv4 and IPv6 | Through Cloudflare's tunnel. `cloudflared`, its connector, runs in production only and hands each request to the ingress |
|
|
145
|
+
| 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 |
|
|
146
|
+
| Where the agent sends | To `lgtm`, with a made-up name and password that nothing checks | To Grafana Cloud, with the secrets that `.env.production.example` names |
|
|
147
|
+
| Each container's memory | No file, so the agent reads none | The host's file `/var/lib/platform/metrics/containers.prom`, which a timer writes every minute |
|
|
148
|
+
| Grafana and the mail catcher | `lgtm` and `mailpit` | Grafana Cloud and Amazon SES |
|
|
149
|
+
| The ingress's own pages | At `traefik.localhost` | Off |
|
|
150
|
+
| The proxy's group | 0, which owns the socket on Docker Desktop | The group that owns the socket on the host, which the deploy passes as `DOCKER_SOCKET_GROUP` |
|
|
146
151
|
|
|
147
152
|
## How to use it, with one worked example
|
|
148
153
|
|
|
@@ -227,6 +232,7 @@ Every product starts the same project, named `platform`. Two products that hold
|
|
|
227
232
|
| ------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
228
233
|
| `Cannot connect to the Docker daemon` | Docker is not running | Start Docker Desktop |
|
|
229
234
|
| `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 |
|
|
235
|
+
| `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
236
|
| `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
237
|
| `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
238
|
| `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
|
@@ -14,6 +14,8 @@ services:
|
|
|
14
14
|
traefik.http.routers.traefik.service: api@internal
|
|
15
15
|
|
|
16
16
|
alloy:
|
|
17
|
+
ports:
|
|
18
|
+
- 127.0.0.1:4318:4318
|
|
17
19
|
environment:
|
|
18
20
|
OTLP_DESTINATION: http://lgtm:4318
|
|
19
21
|
OTLP_USERNAME: local
|
|
@@ -21,17 +23,19 @@ services:
|
|
|
21
23
|
LOKI_DESTINATION: http://lgtm:3100/loki/api/v1/push
|
|
22
24
|
LOKI_USERNAME: local
|
|
23
25
|
LOKI_PASSWORD: local
|
|
26
|
+
TEXTFILE_DIRECTORY: /tmp
|
|
24
27
|
labels:
|
|
25
28
|
traefik.enable: "true"
|
|
26
29
|
traefik.http.routers.alloy.rule: Host(`alloy.localhost`)
|
|
27
30
|
traefik.http.services.alloy.loadbalancer.server.port: "12345"
|
|
28
31
|
|
|
29
32
|
lgtm:
|
|
30
|
-
image: grafana/otel-lgtm:0.41.1
|
|
33
|
+
image: grafana/otel-lgtm:0.41.1@sha256:1b852b77d7bcadb7699bfe7c78a51d059dff85168de674728cf7abf4474645e5
|
|
31
34
|
init: true
|
|
32
35
|
cap_drop: [ALL]
|
|
33
36
|
security_opt: [no-new-privileges:true]
|
|
34
37
|
stop_grace_period: 30s
|
|
38
|
+
restart: unless-stopped
|
|
35
39
|
mem_limit: 2g
|
|
36
40
|
cpus: 2
|
|
37
41
|
environment:
|
|
@@ -50,13 +54,14 @@ services:
|
|
|
50
54
|
networks: [zigordev]
|
|
51
55
|
|
|
52
56
|
mailpit:
|
|
53
|
-
image: axllent/mailpit:v1.34.0
|
|
57
|
+
image: axllent/mailpit:v1.34.0@sha256:23a2ef85bc50853ab3093645d1d64679afd8887e89da5e48a88940c172591a4e
|
|
54
58
|
user: "1000:1000"
|
|
55
59
|
init: true
|
|
56
60
|
read_only: true
|
|
57
61
|
cap_drop: [ALL]
|
|
58
62
|
security_opt: [no-new-privileges:true]
|
|
59
63
|
stop_grace_period: 10s
|
|
64
|
+
restart: unless-stopped
|
|
60
65
|
mem_limit: 128m
|
|
61
66
|
cpus: 0.5
|
|
62
67
|
environment:
|
|
@@ -76,8 +81,9 @@ services:
|
|
|
76
81
|
networks: [zigordev]
|
|
77
82
|
|
|
78
83
|
gcx:
|
|
79
|
-
image: grafana/gcx:v1.8.0
|
|
84
|
+
image: grafana/gcx:v1.8.0@sha256:58347c68228ebc5f36a86bfbdbe353c90aa9452cb961da40ec669e00c8361446
|
|
80
85
|
profiles: [push]
|
|
86
|
+
restart: "no"
|
|
81
87
|
command: [resources, push, --path, /resources, --on-error, abort]
|
|
82
88
|
user: "65532:65532"
|
|
83
89
|
init: true
|
package/compose.yaml
CHANGED
|
@@ -2,7 +2,7 @@ name: platform
|
|
|
2
2
|
|
|
3
3
|
services:
|
|
4
4
|
docker-proxy:
|
|
5
|
-
image: wollomatic/socket-proxy:1.14.0
|
|
5
|
+
image: wollomatic/socket-proxy:1.14.0@sha256:fead157c4de4092461267092be49c993c2e6dd296a54c89ed04b8c870016b045
|
|
6
6
|
command:
|
|
7
7
|
- -loglevel=info
|
|
8
8
|
- -logjson
|
|
@@ -17,6 +17,7 @@ services:
|
|
|
17
17
|
cap_drop: [ALL]
|
|
18
18
|
security_opt: [no-new-privileges:true]
|
|
19
19
|
stop_grace_period: 10s
|
|
20
|
+
restart: unless-stopped
|
|
20
21
|
mem_limit: 64m
|
|
21
22
|
cpus: 0.25
|
|
22
23
|
volumes:
|
|
@@ -29,13 +30,14 @@ services:
|
|
|
29
30
|
networks: [docker]
|
|
30
31
|
|
|
31
32
|
traefik:
|
|
32
|
-
image: traefik:v3.7.19
|
|
33
|
+
image: traefik:v3.7.19@sha256:a6c0194dda77bcb804824580f36fa7edc56e315b1acfe933366c8b52844a78a4
|
|
33
34
|
user: "65532:65532"
|
|
34
35
|
init: true
|
|
35
36
|
read_only: true
|
|
36
37
|
cap_drop: [ALL]
|
|
37
38
|
security_opt: [no-new-privileges:true]
|
|
38
39
|
stop_grace_period: 30s
|
|
40
|
+
restart: unless-stopped
|
|
39
41
|
mem_limit: 128m
|
|
40
42
|
cpus: 1
|
|
41
43
|
environment:
|
|
@@ -66,7 +68,7 @@ services:
|
|
|
66
68
|
networks: [zigordev, docker]
|
|
67
69
|
|
|
68
70
|
alloy:
|
|
69
|
-
image: grafana/alloy:v1.22.0
|
|
71
|
+
image: grafana/alloy:v1.22.0@sha256:9acc2529bc1edb7f5b2bd801dd8334ebc80c158e3a9e5526ecd7c9a273d43189
|
|
70
72
|
entrypoint:
|
|
71
73
|
- sh
|
|
72
74
|
- -c
|
|
@@ -84,6 +86,7 @@ services:
|
|
|
84
86
|
cap_drop: [ALL]
|
|
85
87
|
security_opt: [no-new-privileges:true]
|
|
86
88
|
stop_grace_period: 20s
|
|
89
|
+
restart: unless-stopped
|
|
87
90
|
mem_limit: 256m
|
|
88
91
|
cpus: 1
|
|
89
92
|
environment:
|
|
@@ -190,7 +193,11 @@ services:
|
|
|
190
193
|
procfs_path = "/host/proc"
|
|
191
194
|
sysfs_path = "/host/sys"
|
|
192
195
|
rootfs_path = "/host/root"
|
|
193
|
-
set_collectors = ["cpu", "meminfo", "filesystem"]
|
|
196
|
+
set_collectors = ["cpu", "meminfo", "filesystem", "textfile"]
|
|
197
|
+
|
|
198
|
+
textfile {
|
|
199
|
+
directory = sys.env("TEXTFILE_DIRECTORY")
|
|
200
|
+
}
|
|
194
201
|
}
|
|
195
202
|
|
|
196
203
|
prometheus.scrape "machine" {
|
|
@@ -207,7 +214,7 @@ services:
|
|
|
207
214
|
|
|
208
215
|
rule {
|
|
209
216
|
source_labels = ["__name__", "mode", "fstype"]
|
|
210
|
-
regex = "alloy_build_info;;|node_cpu_seconds_total;idle;|node_memory_(MemTotal|MemAvailable)_bytes;;|node_filesystem_(size|avail)_bytes;;(ext4|xfs)"
|
|
217
|
+
regex = "alloy_build_info;;|node_cpu_seconds_total;idle;|node_memory_(MemTotal|MemAvailable)_bytes;;|node_filesystem_(size|avail)_bytes;;(ext4|xfs)|container_(memory_working_set|spec_memory_limit)_bytes;;"
|
|
211
218
|
action = "keep"
|
|
212
219
|
}
|
|
213
220
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zigordev/stack",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.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",
|