2023-01-16 15:14:20 +00:00
|
|
|
import { mkdir, mkdtemp } from "node:fs/promises";
|
2023-01-16 12:42:10 +00:00
|
|
|
import { tmpdir } from "node:os";
|
|
|
|
import path from "node:path";
|
2023-01-23 15:30:21 +00:00
|
|
|
import { cwd } from "node:process";
|
2023-01-16 15:14:20 +00:00
|
|
|
import { Alpine } from "./alpine.js";
|
|
|
|
import { spawn } from "./helpers.js";
|
2023-01-23 15:30:21 +00:00
|
|
|
import { setupKernel } from "./kernel.js";
|
2023-01-16 15:14:20 +00:00
|
|
|
import { Runit } from "./runit/index.js";
|
2023-01-16 12:42:10 +00:00
|
|
|
|
|
|
|
{
|
2023-01-23 15:30:21 +00:00
|
|
|
console.time("Building");
|
|
|
|
|
2023-01-16 12:42:10 +00:00
|
|
|
const rootfsDir = await mkdtemp(path.join(tmpdir(), "define-alpine-"));
|
|
|
|
console.debug(rootfsDir);
|
2023-01-16 15:14:20 +00:00
|
|
|
const alpine = await Alpine.makeWorld({ dir: rootfsDir });
|
|
|
|
const runit = await Runit.setup(alpine);
|
2023-01-23 15:30:21 +00:00
|
|
|
await setupKernel(alpine);
|
|
|
|
|
|
|
|
console.timeEnd("Building");
|
|
|
|
|
|
|
|
const artifactsDir = path.join(cwd(), "artifacts/");
|
|
|
|
await mkdir(artifactsDir);
|
|
|
|
|
2023-01-16 15:14:20 +00:00
|
|
|
// await makeService({
|
|
|
|
// parentDir: rootfsDir,
|
|
|
|
// name: "grafana",
|
|
|
|
// packages: ["grafana"],
|
|
|
|
// setup: async (dir) => {},
|
|
|
|
// initScript: async (dir) => {},
|
|
|
|
// });
|
2023-01-23 15:30:21 +00:00
|
|
|
// try {
|
|
|
|
// await spawn("sudo", ["chroot", rootfsDir], { stdio: "inherit" });
|
|
|
|
// } catch {}
|
2023-01-16 12:42:10 +00:00
|
|
|
}
|
|
|
|
|
2023-01-16 15:14:20 +00:00
|
|
|
// interface Service {}
|
|
|
|
// async function makeService({
|
|
|
|
// parentDir,
|
|
|
|
// name,
|
|
|
|
// packages,
|
|
|
|
// setup,
|
|
|
|
// initScript: _initScript,
|
|
|
|
// }: {
|
|
|
|
// parentDir: string;
|
|
|
|
// name: string;
|
|
|
|
// packages?: string[];
|
|
|
|
// setup: (dir: string) => Promise<void>;
|
|
|
|
// initScript: (dir: string) => Promise<string>;
|
|
|
|
// }) {
|
|
|
|
// const rootsDir = path.join(parentDir, "/nulo/roots/");
|
|
|
|
// await mkdir(rootsDir, { recursive: true });
|
2023-01-16 12:42:10 +00:00
|
|
|
|
2023-01-16 15:14:20 +00:00
|
|
|
// const alpine = await Alpine.makeWorld({
|
|
|
|
// dir: path.join(rootsDir, name),
|
|
|
|
// packages,
|
|
|
|
// });
|
2023-01-16 12:42:10 +00:00
|
|
|
|
2023-01-16 15:14:20 +00:00
|
|
|
// await setup(alpine.dir);
|
|
|
|
|
|
|
|
// // const initScript = await _initScript(rootfsDir);
|
|
|
|
// }
|