cache
This commit is contained in:
parent
4f6534cd4d
commit
d1bddfe3d7
1 changed files with 8 additions and 2 deletions
10
index.js
10
index.js
|
@ -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",
|
||||||
|
|
Loading…
Reference in a new issue