From ad65f7404e15d1cb1cd1003b6f4fc988450c8e4f Mon Sep 17 00:00:00 2001 From: Enderson Maia Date: Tue, 28 May 2024 11:00:12 +0100 Subject: [PATCH] feat(cli): use cartesi as compose project name --- .changeset/wild-gorillas-decide.md | 5 +++ apps/cli/src/commands/run.ts | 33 +++++-------------- apps/cli/src/node/docker-compose-cartesi.yaml | 1 + 3 files changed, 15 insertions(+), 24 deletions(-) create mode 100644 .changeset/wild-gorillas-decide.md create mode 100644 apps/cli/src/node/docker-compose-cartesi.yaml diff --git a/.changeset/wild-gorillas-decide.md b/.changeset/wild-gorillas-decide.md new file mode 100644 index 00000000..ad949ded --- /dev/null +++ b/.changeset/wild-gorillas-decide.md @@ -0,0 +1,5 @@ +--- +"@cartesi/cli": patch +--- + +use cartesi as compose project name diff --git a/apps/cli/src/commands/run.ts b/apps/cli/src/commands/run.ts index 4dd12bb6..be0261e7 100644 --- a/apps/cli/src/commands/run.ts +++ b/apps/cli/src/commands/run.ts @@ -73,21 +73,6 @@ export default class Run extends BaseCommand { public async run(): Promise { const { flags } = await this.parse(Run); - let projectName: string; - - if (flags["no-backend"]) { - projectName = "cartesi-node"; - } else { - // get machine hash - const hash = this.getMachineHash(); - // Check if snapshot exists - if (!hash) { - throw new Error( - `Cartesi machine snapshot not found, run '${this.config.bin} build'`, - ); - } - projectName = hash.substring(2, 10); - } // path of the tool instalation const binPath = path.join( @@ -118,11 +103,18 @@ export default class Run extends BaseCommand { CARTESI_VALIDATOR_MEMORY: flags.memory?.toString(), }; + // cartesi project name + const composeFiles = ["docker-compose-cartesi.yaml"]; + // validator - const composeFiles = ["docker-compose-validator.yaml"]; + composeFiles.push("docker-compose-validator.yaml"); + + // limit cpu if (flags.cpus) { composeFiles.push("docker-compose-validator-cpus.yaml"); } + + // limit memory if (flags.memory) { composeFiles.push("docker-compose-validator-memory.yaml"); } @@ -171,14 +163,7 @@ export default class Run extends BaseCommand { .map((f) => ["--file", path.join(binPath, "node", f)]) .flat(); - const compose_args = [ - "compose", - ...files, - "--project-directory", - ".", - "--project-name", - projectName, - ]; + const compose_args = ["compose", ...files, "--project-directory", "."]; const up_args = []; diff --git a/apps/cli/src/node/docker-compose-cartesi.yaml b/apps/cli/src/node/docker-compose-cartesi.yaml new file mode 100644 index 00000000..241be776 --- /dev/null +++ b/apps/cli/src/node/docker-compose-cartesi.yaml @@ -0,0 +1 @@ +name: cartesi