(version: string)
| 111 | * Local mode: auto-builds if missing. NPX mode: pulls from Docker Hub. |
| 112 | */ |
| 113 | export function ensureImage(version: string): void { |
| 114 | const image = getWorkerImage(version); |
| 115 | const exists = runQuiet('docker', ['image', 'inspect', image]); |
| 116 | if (exists) return; |
| 117 | |
| 118 | if (getMode() === 'local') { |
| 119 | console.log('Worker image not found, building...'); |
| 120 | buildImage(false); |
| 121 | } else { |
| 122 | console.log(`Pulling ${image}...`); |
| 123 | try { |
| 124 | execFileSync('docker', ['pull', image], { stdio: 'inherit' }); |
| 125 | } catch { |
| 126 | console.error(`\nERROR: Failed to pull ${image}`); |
| 127 | console.error('The image may not be available for your platform yet.'); |
| 128 | console.error('Check https://hub.docker.com/r/keygraph/shannon for available tags.'); |
| 129 | process.exit(1); |
| 130 | } |
| 131 | pruneOldImages(version); |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | /** |
| 136 | * Detect if --add-host is needed (Linux without Podman). |
no test coverage detected