This commit is contained in:
Cat /dev/Nulo 2023-05-31 11:17:19 -03:00
parent 4f6534cd4d
commit d1bddfe3d7

View file

@ -1,5 +1,6 @@
import { execFile as _execFile } from "node:child_process"; import { execFile as _execFile } from "node:child_process";
import { readFile, stat, symlink, writeFile } from "node:fs/promises"; import { mkdir, readFile, stat, symlink, writeFile } from "node:fs/promises";
import { homedir } from "node:os";
import { join } from "node:path"; import { join } from "node:path";
import { promisify } from "node:util"; import { promisify } from "node:util";
const execFile = promisify(_execFile); const execFile = promisify(_execFile);
@ -23,6 +24,7 @@ mkdir -p /rootfs/etc/apk
cp -r /etc/apk/keys /rootfs/etc/apk/ cp -r /etc/apk/keys /rootfs/etc/apk/
echo https://dl-cdn.alpinelinux.org/alpine/v3.18/main >> /rootfs/etc/apk/repositories echo https://dl-cdn.alpinelinux.org/alpine/v3.18/main >> /rootfs/etc/apk/repositories
echo https://dl-cdn.alpinelinux.org/alpine/v3.18/community >> /rootfs/etc/apk/repositories echo https://dl-cdn.alpinelinux.org/alpine/v3.18/community >> /rootfs/etc/apk/repositories
ln -s /var/cache/apk /rootfs/etc/apk/cache
apk add --initdb --root /rootfs alpine-base apk add --initdb --root /rootfs alpine-base
` `
); );
@ -53,12 +55,16 @@ apk add --initdb --root /rootfs alpine-base
* @param {string} script * @param {string} script
*/ */
async function runInContainer(root, script) { async function runInContainer(root, script) {
const cacheDir = join(homedir(), ".cache/apkit");
await mkdir(cacheDir, { recursive: true });
await execFile("podman", [ await execFile("podman", [
"run", "run",
"-it", "-i",
"--rm", "--rm",
"-v", "-v",
`${root}:/rootfs:Z`, `${root}:/rootfs:Z`,
"-v",
`${cacheDir}:/var/cache/apk:Z`,
"docker.io/alpine:3.18", "docker.io/alpine:3.18",
"sh", "sh",
"-ec", "-ec",