Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/dirty-crabs-smoke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cartesi/cli": patch
---

additional config flags to drive machine build
6 changes: 6 additions & 0 deletions apps/cli/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ export type MachineConfig = {
ramLength: string;
ramImage: string;
store?: string;
useDockerEnv: boolean; // inject docker image ENV into cartesi-machine ENV
useDockerWorkdir: boolean; // inject docker image WORKDIR into cartesi-machine WORKDIR
user?: string; // default given by cartesi-machine
};

Expand Down Expand Up @@ -183,6 +185,8 @@ export const defaultMachineConfig = (): MachineConfig => ({
ramLength: DEFAULT_RAM,
ramImage: DEFAULT_RAM_IMAGE,
store: "image",
useDockerEnv: true,
useDockerWorkdir: true,
user: undefined,
});

Expand Down Expand Up @@ -378,6 +382,8 @@ const parseMachine = (value: TomlPrimitive): MachineConfig => {
ramLength: parseString(toml.ram_length, DEFAULT_RAM),
ramImage: parseString(toml.ram_image, DEFAULT_RAM_IMAGE),
store: "image",
useDockerEnv: parseBoolean(toml.use_docker_env, true),
useDockerWorkdir: parseBoolean(toml.use_docker_workdir, true),
user: parseOptionalString(toml.user),
};
};
Expand Down
6 changes: 4 additions & 2 deletions apps/cli/src/machine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ export const bootMachine = (
ramLength,
ramImage,
store,
useDockerEnv,
useDockerWorkdir,
user,
} = machine;

// list of environment variables of docker image
const env = info?.env ?? [];
const env = useDockerEnv ? (info?.env ?? []) : [];
const envs = env.map((variable) => `--env=${variable}`);

// check if we need a rootfstype boot arg
Expand Down Expand Up @@ -92,7 +94,7 @@ export const bootMachine = (
if (finalHash) {
args.push("--final-hash");
}
if (info?.workdir) {
if (useDockerWorkdir && info?.workdir) {
args.push(`--workdir="${info.workdir}"`);
}
if (interactive) {
Expand Down
4 changes: 3 additions & 1 deletion apps/cli/tests/unit/config/fixtures/full.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
# no_rollup = false
# ram_image = "/usr/share/cartesi-machine/images/linux.bin" # directory inside SDK image
# ram_length = "128Mi"
# use_docker_env = true
# use_docker_workdir = true
# user = "dapp"

# [drives.root]
# builder = "docker"
Expand Down Expand Up @@ -41,4 +44,3 @@
# builder = "none"
# filename = "./games/doom.sqfs"
# mount = "/usr/local/games/doom"

Loading