@bakers-build/addon-runtime-docker 0.11.1-next.5 → 0.11.1-next.7

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.
@@ -54,6 +54,27 @@ export function dockerRuntime(options, deps) {
54
54
  ]);
55
55
  }
56
56
  };
57
+ // A read-only mount over the image's install dirs hides the agent; fail here, not at launch.
58
+ const probeAgent = async (image, command) => {
59
+ const mounts = [deps.cliRoot, ...opts.mounts];
60
+ try {
61
+ await deps.exec(docker, [
62
+ 'run',
63
+ '--rm',
64
+ '--user',
65
+ `${process.getuid?.() ?? 1000}:${process.getgid?.() ?? 1000}`,
66
+ ...mounts.flatMap((m) => ['-v', `${m}:${m}:ro`]),
67
+ '--entrypoint',
68
+ 'sh',
69
+ image,
70
+ '-c',
71
+ `command -v ${shellQuote(command)}`,
72
+ ]);
73
+ }
74
+ catch (err) {
75
+ throw new Error(`runtime-docker: ${command} is not found in ${image} with the run's mounts (${mounts.join(', ')}); a mount shadows the image's install (${String(err)})`);
76
+ }
77
+ };
57
78
  const ensureNetwork = async (name, internal) => {
58
79
  try {
59
80
  await deps.exec(docker, ['network', 'inspect', name]);
@@ -143,12 +164,17 @@ export function dockerRuntime(options, deps) {
143
164
  throw new Error(`runtime-docker: agent ${launch.harness} has no installCommand; configure an image`);
144
165
  const image = options.image ??
145
166
  `bakers-runtime:${deps.version}-${shortHash(launch.installCommand ?? '')}`;
146
- if (!imagesReady.has(image))
147
- imagesReady.set(image, ensureImage(image, launch.installCommand ?? '').catch((err) => {
148
- imagesReady.delete(image);
167
+ // An agent with an installCommand is installed in the image as its harness id.
168
+ const probe = launch.installCommand ? launch.harness : undefined;
169
+ const ready = `${image}\0${probe ?? ''}`;
170
+ if (!imagesReady.has(ready))
171
+ imagesReady.set(ready, ensureImage(image, launch.installCommand ?? '')
172
+ .then(() => (probe ? probeAgent(image, probe) : undefined))
173
+ .catch((err) => {
174
+ imagesReady.delete(ready);
149
175
  throw err;
150
176
  }));
151
- await imagesReady.get(image);
177
+ await imagesReady.get(ready);
152
178
  if (allowlist) {
153
179
  if (!gateway || !toolsPort)
154
180
  throw new Error('runtime-docker: allowlist mode needs the conductor tool server; it was not started');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bakers-build/addon-runtime-docker",
3
- "version": "0.11.1-next.5",
3
+ "version": "0.11.1-next.7",
4
4
  "description": "Start each agent run in its own Docker or Podman container.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -23,11 +23,11 @@
23
23
  "directory": "bakers-cli/addons/runtime-docker"
24
24
  },
25
25
  "peerDependencies": {
26
- "@bakers-build/conductor": "^0.11.1-next.5",
27
- "@bakers-build/core": "^0.11.1-next.5"
26
+ "@bakers-build/conductor": "^0.11.1-next.7",
27
+ "@bakers-build/core": "^0.11.1-next.7"
28
28
  },
29
29
  "bakersBuild": {
30
- "commit": "d7535c4db571b4de2a9929185070384a00907595",
30
+ "commit": "9f305d0873788b79f7af9e8eb650eb4115fa72d6",
31
31
  "channel": "next"
32
32
  }
33
33
  }