@zigordev/stack 1.1.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 +29 -26
- package/compose.local.yaml +7 -3
- package/compose.yaml +12 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -97,24 +97,26 @@ A new app needs no entry anywhere. It appears in the list of the App dashboard w
|
|
|
97
97
|
|
|
98
98
|
### Each container is boxed in
|
|
99
99
|
|
|
100
|
-
| Rule | Why
|
|
101
|
-
| ------------------------------------------------------------------------------------------------------- |
|
|
102
|
-
| An exact image version
|
|
103
|
-
| A health check | `up` can wait for it, and the ingress can trust it
|
|
104
|
-
| A
|
|
105
|
-
|
|
|
106
|
-
|
|
|
107
|
-
|
|
|
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 |
|
|
108
109
|
|
|
109
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.
|
|
110
111
|
|
|
111
|
-
| Service | Memory limit | CPU limit | Used when idle on 2026-11-22
|
|
112
|
-
| -------------- | ------------ | --------- |
|
|
113
|
-
| `traefik` | 128 MiB | 1 | 24 MiB
|
|
114
|
-
| `docker-proxy` | 64 MiB | 0.25 | 11 MiB
|
|
115
|
-
| `alloy` | 256 MiB | 1 | 51 MiB
|
|
116
|
-
| `lgtm` | 2 GiB | 2 | 614 MiB
|
|
117
|
-
| `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 |
|
|
118
120
|
|
|
119
121
|
### The Docker proxy
|
|
120
122
|
|
|
@@ -134,17 +136,18 @@ Traefik warns once at each start that it "can reject some encoded characters in
|
|
|
134
136
|
|
|
135
137
|
### The laptop and production
|
|
136
138
|
|
|
137
|
-
|
|
138
|
-
|
|
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,
|
|
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
|
-
|
|
|
146
|
-
|
|
|
147
|
-
| The
|
|
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.
|
|
140
|
+
|
|
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` |
|
|
148
151
|
|
|
149
152
|
## How to use it, with one worked example
|
|
150
153
|
|
package/compose.local.yaml
CHANGED
|
@@ -23,17 +23,19 @@ services:
|
|
|
23
23
|
LOKI_DESTINATION: http://lgtm:3100/loki/api/v1/push
|
|
24
24
|
LOKI_USERNAME: local
|
|
25
25
|
LOKI_PASSWORD: local
|
|
26
|
+
TEXTFILE_DIRECTORY: /tmp
|
|
26
27
|
labels:
|
|
27
28
|
traefik.enable: "true"
|
|
28
29
|
traefik.http.routers.alloy.rule: Host(`alloy.localhost`)
|
|
29
30
|
traefik.http.services.alloy.loadbalancer.server.port: "12345"
|
|
30
31
|
|
|
31
32
|
lgtm:
|
|
32
|
-
image: grafana/otel-lgtm:0.41.1
|
|
33
|
+
image: grafana/otel-lgtm:0.41.1@sha256:1b852b77d7bcadb7699bfe7c78a51d059dff85168de674728cf7abf4474645e5
|
|
33
34
|
init: true
|
|
34
35
|
cap_drop: [ALL]
|
|
35
36
|
security_opt: [no-new-privileges:true]
|
|
36
37
|
stop_grace_period: 30s
|
|
38
|
+
restart: unless-stopped
|
|
37
39
|
mem_limit: 2g
|
|
38
40
|
cpus: 2
|
|
39
41
|
environment:
|
|
@@ -52,13 +54,14 @@ services:
|
|
|
52
54
|
networks: [zigordev]
|
|
53
55
|
|
|
54
56
|
mailpit:
|
|
55
|
-
image: axllent/mailpit:v1.34.0
|
|
57
|
+
image: axllent/mailpit:v1.34.0@sha256:23a2ef85bc50853ab3093645d1d64679afd8887e89da5e48a88940c172591a4e
|
|
56
58
|
user: "1000:1000"
|
|
57
59
|
init: true
|
|
58
60
|
read_only: true
|
|
59
61
|
cap_drop: [ALL]
|
|
60
62
|
security_opt: [no-new-privileges:true]
|
|
61
63
|
stop_grace_period: 10s
|
|
64
|
+
restart: unless-stopped
|
|
62
65
|
mem_limit: 128m
|
|
63
66
|
cpus: 0.5
|
|
64
67
|
environment:
|
|
@@ -78,8 +81,9 @@ services:
|
|
|
78
81
|
networks: [zigordev]
|
|
79
82
|
|
|
80
83
|
gcx:
|
|
81
|
-
image: grafana/gcx:v1.8.0
|
|
84
|
+
image: grafana/gcx:v1.8.0@sha256:58347c68228ebc5f36a86bfbdbe353c90aa9452cb961da40ec669e00c8361446
|
|
82
85
|
profiles: [push]
|
|
86
|
+
restart: "no"
|
|
83
87
|
command: [resources, push, --path, /resources, --on-error, abort]
|
|
84
88
|
user: "65532:65532"
|
|
85
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",
|