@norskvideo/ctl-sdk 0.1.23 → 0.1.24

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.
@@ -4,10 +4,17 @@ export declare const CONTAINER_INTERNAL_PORT = 4321;
4
4
  * `norsk-ctl.role` label (proxy, proxy-oauth2, cpu-monitor, product); the
5
5
  * value doubles as the card's component name. */
6
6
  export declare const PRODUCT_ROLE_LABEL = "norsk-ctl.role=product";
7
+ /** How to place a product container. The network is the host's call: ctl puts
8
+ * the control plane on the same bridge as nginx and every launched instance,
9
+ * which is what makes it reachable from a daemon that is itself a container
10
+ * (see product-reach.ts). Omitted leaves it on docker's default bridge. */
11
+ export interface ProductRunOpts {
12
+ network?: string;
13
+ }
7
14
  /** argv (sans leading "docker") that launches a product container: detached,
8
15
  * auto-removed, loopback-published to its internal 4321, and role-labelled so
9
16
  * it shows up in the Infrastructure tab. */
10
- export declare function productRunArgs(image: string, hostPort: number): string[];
17
+ export declare function productRunArgs(image: string, hostPort: number, opts?: ProductRunOpts): string[];
11
18
  /** Stable container name for a product, derived from its manifest name, so
12
19
  * `docker ps` shows `norsk-product-studio` instead of a random docker alias.
13
20
  * Mirrors the singleton naming of norsk-proxy / norsk-ctl-cpu-monitor. */
@@ -16,7 +23,7 @@ export declare function productContainerName(productName: string): string;
16
23
  * so there is nothing to refresh; a tag can move under a registration. */
17
24
  export declare function isDigestRef(image: string): boolean;
18
25
  export declare function dockerPull(image: string): Promise<void>;
19
- export declare function dockerRun(image: string, hostPort: number): Promise<string>;
26
+ export declare function dockerRun(image: string, hostPort: number, opts?: ProductRunOpts): Promise<string>;
20
27
  /** The container's address on its first network (the default bridge for a
21
28
  * product container), or undefined when docker cannot say. */
22
29
  export declare function dockerAddress(containerId: string): Promise<string | undefined>;
package/docker-runner.js CHANGED
@@ -8,13 +8,14 @@ export const PRODUCT_ROLE_LABEL = "norsk-ctl.role=product";
8
8
  /** argv (sans leading "docker") that launches a product container: detached,
9
9
  * auto-removed, loopback-published to its internal 4321, and role-labelled so
10
10
  * it shows up in the Infrastructure tab. */
11
- export function productRunArgs(image, hostPort) {
11
+ export function productRunArgs(image, hostPort, opts = {}) {
12
12
  return [
13
13
  "run",
14
14
  "-d",
15
15
  "--rm",
16
16
  "--label",
17
17
  PRODUCT_ROLE_LABEL,
18
+ ...(opts.network ? ["--network", opts.network] : []),
18
19
  "-p",
19
20
  `127.0.0.1:${hostPort}:${CONTAINER_INTERNAL_PORT}`,
20
21
  image,
@@ -43,8 +44,8 @@ export async function dockerPull(image) {
43
44
  throw new ProductError("DOCKER_PULL_FAILED", `docker pull failed (exit ${exitCode}): ${stderr || "no stderr"}`);
44
45
  }
45
46
  }
46
- export async function dockerRun(image, hostPort) {
47
- const proc = Bun.spawn(["docker", ...productRunArgs(image, hostPort)], { stdout: "pipe", stderr: "pipe" });
47
+ export async function dockerRun(image, hostPort, opts = {}) {
48
+ const proc = Bun.spawn(["docker", ...productRunArgs(image, hostPort, opts)], { stdout: "pipe", stderr: "pipe" });
48
49
  const exitCode = await proc.exited;
49
50
  const stdout = (await new Response(proc.stdout).text()).trim();
50
51
  const stderr = (await new Response(proc.stderr).text()).trim();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@norskvideo/ctl-sdk",
3
- "version": "0.1.23",
3
+ "version": "0.1.24",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {