alwaysai
Version:
The alwaysAI command-line interface (CLI)
55 lines • 1.9 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const spawner_base_1 = require("./spawner-base");
const gnu_spawner_1 = require("./gnu-spawner");
const os_1 = require("os");
const resolve_posix_path_1 = require("../util/resolve-posix-path");
exports.IMAGE_NAME = 'alwaysai/edgeiq';
exports.APP_DIR = '/app';
function DockerSpawner() {
const resolvePath = resolve_posix_path_1.ResolvePosixPath(exports.APP_DIR);
const gnuSpawner = gnu_spawner_1.GnuSpawner(Object.assign({ resolvePath }, spawner_base_1.SpawnerBase(translate)));
return Object.assign({}, gnuSpawner, { rimraf(path) {
if (!path || resolvePath(path) === resolvePath()) {
throw new Error('Refusing to delete whole directory because it is mirrored');
}
return gnuSpawner.rimraf(path);
} });
function translate(cmd) {
const args = [
'run',
'--rm',
'--privileged',
'--interactive',
'--volume',
`${process.cwd()}:${resolvePath()}`,
];
if (cmd.expose5000) {
if (os_1.platform() === 'linux') {
args.push('--network=host');
}
else {
args.push('--publish', '127.0.0.1:5000:5000/tcp');
}
}
if (os_1.platform() !== 'win32') {
args.push('--volume', '/dev:/dev');
}
if (cmd.tty) {
args.push('--tty');
}
args.push('--workdir', resolvePath(cmd.cwd));
args.push(exports.IMAGE_NAME, cmd.exe);
if (cmd.args) {
args.push(...cmd.args);
}
const translated = {
exe: 'docker',
args,
input: cmd.input,
};
return translated;
}
}
exports.DockerSpawner = DockerSpawner;
//# sourceMappingURL=docker-spawner.js.map