mejorar uso de podman
This commit is contained in:
parent
d10ed631da
commit
74091874d7
2 changed files with 27 additions and 15 deletions
14
index.js
14
index.js
|
@ -1,4 +1,4 @@
|
||||||
import { execFile as _execFile } from "node:child_process";
|
import { execFile as _execFile, spawn } from "node:child_process";
|
||||||
import { mkdir, readFile, stat, symlink, writeFile } from "node:fs/promises";
|
import { mkdir, readFile, stat, symlink, writeFile } from "node:fs/promises";
|
||||||
import { homedir } from "node:os";
|
import { homedir } from "node:os";
|
||||||
import { join } from "node:path";
|
import { join } from "node:path";
|
||||||
|
@ -52,6 +52,7 @@ apk add --initdb --root /rootfs alpine-base
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const IS_DEV = process.env.NODE_ENV === "development";
|
||||||
/**
|
/**
|
||||||
* Run script inside an Alpine 3.18 container with `root` mounted in /rootfs
|
* Run script inside an Alpine 3.18 container with `root` mounted in /rootfs
|
||||||
* @param {string} root
|
* @param {string} root
|
||||||
|
@ -60,7 +61,9 @@ apk add --initdb --root /rootfs alpine-base
|
||||||
async function runInContainer(root, script) {
|
async function runInContainer(root, script) {
|
||||||
const cacheDir = join(homedir(), ".cache/apkit");
|
const cacheDir = join(homedir(), ".cache/apkit");
|
||||||
await mkdir(cacheDir, { recursive: true });
|
await mkdir(cacheDir, { recursive: true });
|
||||||
await execFile("podman", [
|
const proc = spawn(
|
||||||
|
"podman",
|
||||||
|
[
|
||||||
"run",
|
"run",
|
||||||
"-i",
|
"-i",
|
||||||
"--rm",
|
"--rm",
|
||||||
|
@ -72,5 +75,10 @@ async function runInContainer(root, script) {
|
||||||
"sh",
|
"sh",
|
||||||
"-ec",
|
"-ec",
|
||||||
script,
|
script,
|
||||||
]);
|
],
|
||||||
|
{ stdio: IS_DEV ? "inherit" : "pipe" }
|
||||||
|
);
|
||||||
|
await new Promise((resolve, reject) =>
|
||||||
|
proc.on("exit", (code) => (code === 0 ? resolve(void 0) : reject(code)))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
lockfileVersion: '6.0'
|
lockfileVersion: '6.1'
|
||||||
|
|
||||||
|
settings:
|
||||||
|
autoInstallPeers: true
|
||||||
|
excludeLinksFromLockfile: false
|
||||||
|
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@tsconfig/node16':
|
'@tsconfig/node16':
|
||||||
|
|
Loading…
Reference in a new issue