@north-light/env-docker 0.3.420 → 0.3.422
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 +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +11 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -37,7 +37,7 @@ console.log(await client.system.health());
|
|
|
37
37
|
await env.stop();
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
`start()` creates a container from `ghcr.io/northlight-systems/crtrd:latest` unless you pass `image`, generates a bearer token, binds the mapped port to `127.0.0.1`, and waits for `/healthz`. `connection()` returns `{ baseURL, headers }`, the shape `new Crouter(...)` takes. `stop()` removes the container.
|
|
40
|
+
`start()` creates a container from `ghcr.io/northlight-systems/crtrd:latest` unless you pass `image`, generates a bearer token, grants the privileges the image's sandbox launcher needs (`SYS_ADMIN` and `NET_ADMIN`, unconfined seccomp and AppArmor), binds the mapped port to `127.0.0.1`, and waits for `/healthz`. `connection()` returns `{ baseURL, headers }`, the shape `new Crouter(...)` takes. `stop()` removes the container.
|
|
41
41
|
|
|
42
42
|
Options: `env` sets container environment variables, `port` selects a host port, `volume` mounts a named Docker volume at the crouter home. A named volume keeps canvas state and memory when the container is recreated.
|
|
43
43
|
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ export type { Connection, DockerEnvironment, StartOptions };
|
|
|
6
6
|
* locally built tag (e.g. `crtrd:local`).
|
|
7
7
|
*/
|
|
8
8
|
export declare const DEFAULT_IMAGE = "ghcr.io/northlight-systems/crtrd:latest";
|
|
9
|
+
/** `docker run` flags the image's sandbox launcher needs. */
|
|
10
|
+
export declare const LAUNCHER_PRIVILEGES: readonly ["--cap-add", "SYS_ADMIN", "--cap-add", "NET_ADMIN", "--security-opt", "seccomp=unconfined", "--security-opt", "apparmor=unconfined"];
|
|
9
11
|
/** Run the crtrd image, wait until `/healthz` answers 200 through the mapped
|
|
10
12
|
* port, and return its connection settings. `stop()` stops and
|
|
11
13
|
* removes the container. */
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,13 @@ import { CONTAINER_PORT, inspectContainer, isContainerRunning, readHostPortFromI
|
|
|
8
8
|
* locally built tag (e.g. `crtrd:local`).
|
|
9
9
|
*/
|
|
10
10
|
export const DEFAULT_IMAGE = 'ghcr.io/northlight-systems/crtrd:latest';
|
|
11
|
+
/** `docker run` flags the image's sandbox launcher needs. */
|
|
12
|
+
export const LAUNCHER_PRIVILEGES = [
|
|
13
|
+
'--cap-add', 'SYS_ADMIN',
|
|
14
|
+
'--cap-add', 'NET_ADMIN',
|
|
15
|
+
'--security-opt', 'seccomp=unconfined',
|
|
16
|
+
'--security-opt', 'apparmor=unconfined',
|
|
17
|
+
];
|
|
11
18
|
const HEALTH_TIMEOUT_MS = 60_000;
|
|
12
19
|
const HEALTH_INTERVAL_MS = 300;
|
|
13
20
|
function generateToken() {
|
|
@@ -23,7 +30,10 @@ export async function start(opts = {}) {
|
|
|
23
30
|
const image = opts.image ?? DEFAULT_IMAGE;
|
|
24
31
|
const name = opts.name ?? generateName();
|
|
25
32
|
const token = generateToken();
|
|
26
|
-
|
|
33
|
+
// The image's root launcher installs iptables rules and builds bubblewrap
|
|
34
|
+
// sandboxes for each agent, so it needs the same privileges hosting grants
|
|
35
|
+
// its guests; without them it exits before /healthz ever answers.
|
|
36
|
+
const args = ['run', '-d', '--name', name, '-e', `CRTRD_TOKEN=${token}`, ...LAUNCHER_PRIVILEGES];
|
|
27
37
|
for (const [key, value] of Object.entries(opts.env ?? {})) {
|
|
28
38
|
args.push('-e', `${key}=${value}`);
|
|
29
39
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@north-light/env-docker",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.422",
|
|
4
4
|
"description": "Docker connection manager for the crouter SDK — start, attach to, and stop a crtrd container over the docker CLI. Zero crouter imports.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|