From 8ec7c5b944756eadb652d53948b5461d49f86759 Mon Sep 17 00:00:00 2001 From: Danilo Tuler Date: Fri, 11 Oct 2024 13:13:47 -0400 Subject: [PATCH 1/2] fixup! feat(cli): build based on configuration suport to docker build context --- apps/cli/src/builder/docker.ts | 7 ++++--- apps/cli/src/config.ts | 4 ++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/apps/cli/src/builder/docker.ts b/apps/cli/src/builder/docker.ts index f145518f..51094ac1 100644 --- a/apps/cli/src/builder/docker.ts +++ b/apps/cli/src/builder/docker.ts @@ -8,7 +8,7 @@ import { tarToExt } from "./index.js"; type ImageBuildOptions = Pick< DockerDriveConfig, - "dockerfile" | "tags" | "target" + "context" | "dockerfile" | "tags" | "target" >; type ImageInfo = { @@ -22,7 +22,7 @@ type ImageInfo = { * Build Docker image (linux/riscv64). Returns image id. */ const buildImage = async (options: ImageBuildOptions): Promise => { - const { dockerfile, tags, target } = options; + const { context, dockerfile, tags, target } = options; const buildResult = tmp.tmpNameSync(); const args = [ "buildx", @@ -32,6 +32,7 @@ const buildImage = async (options: ImageBuildOptions): Promise => { "--load", "--iidfile", buildResult, + context, ]; // set tags for the image built @@ -41,7 +42,7 @@ const buildImage = async (options: ImageBuildOptions): Promise => { args.push("--target", target); } - await execa("docker", [...args, process.cwd()], { stdio: "inherit" }); + await execa("docker", args, { stdio: "inherit" }); return fs.readFileSync(buildResult, "utf8"); }; diff --git a/apps/cli/src/config.ts b/apps/cli/src/config.ts index de972761..9f58420c 100644 --- a/apps/cli/src/config.ts +++ b/apps/cli/src/config.ts @@ -35,6 +35,7 @@ export type DirectoryDriveConfig = { export type DockerDriveConfig = { builder: "docker"; + context: string; dockerfile: string; extraSize: number; // default is 0 (no extra size) format: DriveFormat; @@ -98,6 +99,7 @@ type TomlTable = { [key: string]: TomlPrimitive }; export const defaultRootDriveConfig = (): DriveConfig => ({ builder: "docker", + context: ".", dockerfile: "Dockerfile", // file on current working directory extraSize: 0, format: DEFAULT_FORMAT, @@ -333,6 +335,7 @@ const parseDrive = (drive: TomlPrimitive): DriveConfig => { } case "docker": { const { + context, dockerfile, extraSize, format, @@ -346,6 +349,7 @@ const parseDrive = (drive: TomlPrimitive): DriveConfig => { return { builder: "docker", image: parseOptionalString(image), + context: parseString(context, "."), dockerfile: parseString(dockerfile, "Dockerfile"), extraSize: parseBytes(extraSize, 0), format: parseFormat(format), From febc8e09c6391f76b85396d5e29cadcea89e9917 Mon Sep 17 00:00:00 2001 From: Danilo Tuler Date: Fri, 11 Oct 2024 16:07:41 -0400 Subject: [PATCH 2/2] fixup! feat(cli): build based on configuration definition of rootfstype --- apps/cli/src/machine.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/apps/cli/src/machine.ts b/apps/cli/src/machine.ts index 3977d2c3..3b37afc7 100644 --- a/apps/cli/src/machine.ts +++ b/apps/cli/src/machine.ts @@ -42,6 +42,18 @@ export const bootMachine = async ( (variable) => `--append-entrypoint=export "${variable}"`, ); + // check if we need a rootfstype boot arg + const root = config.drives.root; + if (root?.format === "sqfs") { + const definedRootfsType = config.machine.bootargs.find((arg) => + arg.startsWith("rootfstype="), + ); + // not checking here if user intentionally defined wrong type + if (!definedRootfsType) { + config.machine.bootargs.push("rootfstype=squashfs"); + } + } + // bootargs from config string array const bootargs = machine.bootargs.map( (arg) => `--append-bootargs="${arg}"`,