feat(server): run managed Ollama on Linux and skip CUDA downloads on install (P1.3b)
- Pinned Ollama 0.32.3 (and rollback 0.32.0) Linux x64/arm64 artifacts with their published SHA-256 and sizes; .tar.zst archives are decompressed by Node 22's zstd and unpacked by the system tar. - install.sh sets ONNXRUNTIME_NODE_INSTALL_CUDA=skip: onnxruntime-node otherwise downloads CUDA libraries on every Linux x64 install. - Drop the root sqlite-vec-windows-x64 dependency; the sqlite-vec package already carries per-platform binaries.
This commit is contained in:
@@ -21,6 +21,7 @@ import path from 'node:path';
|
||||
import { Readable, Transform } from 'node:stream';
|
||||
import { pipeline } from 'node:stream/promises';
|
||||
import { promisify } from 'node:util';
|
||||
import zlib from 'node:zlib';
|
||||
import { createLogger } from './logger.js';
|
||||
|
||||
const execFileAsync = promisify(execFile);
|
||||
@@ -196,6 +197,26 @@ export const OLLAMA_RUNTIME_ARTIFACTS: ReadonlyArray<OllamaRuntimeArtifact> = [
|
||||
sizeBytes: 145_356_966,
|
||||
executableName: 'ollama',
|
||||
},
|
||||
{
|
||||
version: OLLAMA_ROLLBACK_VERSION,
|
||||
platform: 'linux',
|
||||
arch: 'x64',
|
||||
filename: 'ollama-linux-amd64.tar.zst',
|
||||
url: `${ollamaReleaseRoot(OLLAMA_ROLLBACK_VERSION)}/ollama-linux-amd64.tar.zst`,
|
||||
sha256: '56362d7609dfa9e35aaebb7c9cab25605d8f0528ec3d5d585dc83d6642002bab',
|
||||
sizeBytes: 1_436_128_693,
|
||||
executableName: 'ollama',
|
||||
},
|
||||
{
|
||||
version: OLLAMA_ROLLBACK_VERSION,
|
||||
platform: 'linux',
|
||||
arch: 'arm64',
|
||||
filename: 'ollama-linux-arm64.tar.zst',
|
||||
url: `${ollamaReleaseRoot(OLLAMA_ROLLBACK_VERSION)}/ollama-linux-arm64.tar.zst`,
|
||||
sha256: '2c1fbc47a5351c74f5400d7e4b1104bb470291af5d2f425c37c151487a477ad6',
|
||||
sizeBytes: 1_556_234_636,
|
||||
executableName: 'ollama',
|
||||
},
|
||||
{
|
||||
version: OLLAMA_TARGET_VERSION,
|
||||
platform: 'win32',
|
||||
@@ -236,6 +257,26 @@ export const OLLAMA_RUNTIME_ARTIFACTS: ReadonlyArray<OllamaRuntimeArtifact> = [
|
||||
sizeBytes: 145_790_989,
|
||||
executableName: 'ollama',
|
||||
},
|
||||
{
|
||||
version: OLLAMA_TARGET_VERSION,
|
||||
platform: 'linux',
|
||||
arch: 'x64',
|
||||
filename: 'ollama-linux-amd64.tar.zst',
|
||||
url: `${ollamaReleaseRoot(OLLAMA_TARGET_VERSION)}/ollama-linux-amd64.tar.zst`,
|
||||
sha256: '2597d74fbe654ef6a37db56f771cf37d4a85c6bde4018127874e3927d3113800',
|
||||
sizeBytes: 1_421_853_873,
|
||||
executableName: 'ollama',
|
||||
},
|
||||
{
|
||||
version: OLLAMA_TARGET_VERSION,
|
||||
platform: 'linux',
|
||||
arch: 'arm64',
|
||||
filename: 'ollama-linux-arm64.tar.zst',
|
||||
url: `${ollamaReleaseRoot(OLLAMA_TARGET_VERSION)}/ollama-linux-arm64.tar.zst`,
|
||||
sha256: '61af0def977ffc9e76cc961f9505d621805653c63f444796de2f77b4eaaa7047',
|
||||
sizeBytes: 1_542_500_407,
|
||||
executableName: 'ollama',
|
||||
}
|
||||
];
|
||||
|
||||
interface InstallMetadata {
|
||||
@@ -425,6 +466,10 @@ async function defaultExtract(
|
||||
destination: string,
|
||||
artifact: OllamaRuntimeArtifact,
|
||||
): Promise<void> {
|
||||
if (artifact.filename.endsWith('.tar.zst')) {
|
||||
await extractTarZst(archivePath, destination);
|
||||
return;
|
||||
}
|
||||
const executable = artifact.platform === 'win32' ? 'tar.exe' : 'tar';
|
||||
await execFileAsync(executable, ['-xf', archivePath, '-C', destination], {
|
||||
windowsHide: true,
|
||||
@@ -432,6 +477,26 @@ async function defaultExtract(
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Linux releases are zstd-compressed tarballs. Node 22 decompresses zstd itself
|
||||
* and the system tar only unpacks; on older Node, tar needs zstd support.
|
||||
*/
|
||||
export async function extractTarZst(archivePath: string, destination: string): Promise<void> {
|
||||
const createZstdDecompress = (zlib as { createZstdDecompress?: () => Transform }).createZstdDecompress;
|
||||
if (!createZstdDecompress) {
|
||||
await execFileAsync('tar', ['--zstd', '-xf', archivePath, '-C', destination], { timeout: 10 * 60_000 });
|
||||
return;
|
||||
}
|
||||
const tar = spawn('tar', ['-xf', '-', '-C', destination], { stdio: ['pipe', 'ignore', 'pipe'] });
|
||||
let stderr = '';
|
||||
tar.stderr?.on('data', (chunk: Buffer) => { stderr += chunk.toString(); });
|
||||
const exited = new Promise<void>((resolve, reject) => {
|
||||
tar.once('error', reject);
|
||||
tar.once('close', (code) => (code === 0 ? resolve() : reject(new Error(`tar exited with ${code}: ${stderr.trim()}`))));
|
||||
});
|
||||
await Promise.all([pipeline(createReadStream(archivePath), createZstdDecompress(), tar.stdin!), exited]);
|
||||
}
|
||||
|
||||
function inside(root: string, candidate: string): boolean {
|
||||
const relative = path.relative(path.resolve(root), path.resolve(candidate));
|
||||
return relative === '' || (!relative.startsWith('..') && !path.isAbsolute(relative));
|
||||
|
||||
Reference in New Issue
Block a user