Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): use cartesi as compose project name #32

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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/wild-gorillas-decide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cartesi/cli": patch
---

use cartesi as compose project name
33 changes: 9 additions & 24 deletions apps/cli/src/commands/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,6 @@

public async run(): Promise<void> {
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(
Expand Down Expand Up @@ -118,11 +103,18 @@
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");
}
Expand Down Expand Up @@ -171,14 +163,7 @@
.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 = [];

Expand Down Expand Up @@ -208,7 +193,7 @@
});
} catch (e: unknown) {
// 130 is a graceful shutdown, so we can swallow it
if ((e as any).exitCode !== 130) {

Check warning on line 196 in apps/cli/src/commands/run.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
throw e;
}
} finally {
Expand Down
1 change: 1 addition & 0 deletions apps/cli/src/node/docker-compose-cartesi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name: cartesi
Loading