Compare commits

...

6 commits

Author SHA1 Message Date
Cat /dev/Nulo e349bc7cad guardar en .downloading cuando todavía no se bajó 2023-07-17 19:48:21 -03:00
Cat /dev/Nulo 8cd396335a tsconfig: borrar innecesario 2023-07-17 19:23:38 -03:00
Cat /dev/Nulo 35376269b3 tsconfig es2022 2023-07-17 19:14:18 -03:00
Cat /dev/Nulo 0b265c5bc3 invert layer order 2023-07-17 19:14:08 -03:00
Cat /dev/Nulo 879a5f1433 renombrar a cacheDir 2023-07-17 19:05:54 -03:00
Cat /dev/Nulo 1f410fc847 borrar conflist
no usamos esto en el server actual
2023-07-17 19:02:15 -03:00
4 changed files with 10 additions and 27 deletions

View file

@ -1,18 +0,0 @@
{
"name": "fcnet",
"cniVersion": "0.4.0",
"plugins": [
{
"type": "ptp",
"ipMasq": true,
"ipam": {
"type": "host-local",
"subnet": "192.168.127.0/24",
"resolvConf": "/etc/resolv.conf"
}
},
{
"type": "tc-redirect-tap"
}
]
}

View file

@ -1,5 +1,5 @@
import { execFile as _execFile } from "node:child_process";
import { access, mkdir, open, writeFile } from "node:fs/promises";
import { access, mkdir, open, rename, writeFile } from "node:fs/promises";
import { join } from "node:path";
import { tar2squashfs } from "./tar2squashfs.js";
import { subtle } from "node:crypto";
@ -10,7 +10,7 @@ type RegistrySecret = string;
const getToken = memoizeDownloader(_getToken);
let squashfsDownloads = new Map<string, Promise<string>>();
const tmpDir = "cache/";
const cacheDir = "cache/";
// {
// const image = "gitea.nulo.in/nulo/zulip-checkin-cyborg";
// const tag = "latest";
@ -27,7 +27,7 @@ export function parseImageRef(ref: string): { image: string; tag: string } {
}
export async function downloadImage(image: string, tag: string) {
await mkdir(tmpDir, { recursive: true });
await mkdir(cacheDir, { recursive: true });
const manifest = await getManifest(image, tag);
// sanity check
@ -75,7 +75,8 @@ async function saveSquashfs(
let p = squashfsDownloads.get(key);
if (!p) {
p = (async () => {
const output = join(tmpDir, key);
const output = join(cacheDir, key);
const progressFile = output + ".downloading";
try {
await access(output);
// ya está cacheado
@ -92,7 +93,7 @@ async function saveSquashfs(
const res = await getBlob(image, layer.digest);
return res.body!;
});
await tar2squashfs(layerStreams, output, [
await tar2squashfs(layerStreams, progressFile, [
{
content: configJson,
headers: {
@ -103,6 +104,7 @@ async function saveSquashfs(
},
},
]);
await rename(progressFile, output);
}
return output;
})();

View file

@ -48,7 +48,9 @@ export async function tar2squashfs(streams, output, extraFiles) {
p.pipe(child.stdin);
p.on("error", console.error);
for (const streamP of streams) {
// We reverse the arrays because mksquashfs ignores files if they already exist,
// so we leave the last layers first so they are the ones used instead of the last ones
for (const streamP of [...streams].reverse()) {
const stream = await streamP;
const ex = extract();

View file

@ -3,9 +3,6 @@
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"lib": ["es2023"],
"module": "Node16",
"target": "es2022",
"noEmit": true
}
}