Skip to content

feat: print build logs on verbose mode#499

Open
brunomenezes wants to merge 2 commits into
prerelease/v2-alphafrom
feat/print-build-logs-on-verbose-opt
Open

feat: print build logs on verbose mode#499
brunomenezes wants to merge 2 commits into
prerelease/v2-alphafrom
feat/print-build-logs-on-verbose-opt

Conversation

@brunomenezes

Copy link
Copy Markdown
Contributor

Summary

Currently, the cartesi build command, when using Docker under the hood, is in silent mode even when the --verbose flag is passed. If the build takes a while to happen, the user has no idea what is going on unless they realize to go into docker desktop -> builds -> click tab active build -> tab logs and have a look at the current situation. However, in a CI environment, that is not an option.

Now, by passing the --verbose flag, you will be able to see the logs of the Docker build.

PS: We're dogfooding by enabling it on our own integration tests that require an application to be built before the cases are run against it.

@changeset-bot

changeset-bot Bot commented Jul 1, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6c4c342

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@cartesi/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@brunomenezes brunomenezes moved this from Todo to In progress in Rollups SDK Jul 1, 2026
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Coverage Report

Status Category Percentage Covered / Total
🟢 Lines 98.6% (🎯 0%) 4848 / 4917
🔵 Statements 98.6% 4848 / 4917
🔵 Functions 94.78% 127 / 134
🔵 Branches 0% 0 / 0
📁 File Coverage (19 files)
File Lines Statements Functions Branches Uncovered Lines
apps/cli/src/builder/directory.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/builder/docker.ts 🟢 86.72% 🟢 86.72% 🟡 66.67% 🔴 0% 75-77, 79, 109-111, 169-178
apps/cli/src/builder/empty.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/builder/none.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/builder/tar.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/compose/builder.ts 🟢 99.79% 🟢 99.79% 🟢 100% 🔴 0% 228
apps/cli/src/compose/common.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/compose/node.ts 🟢 99.24% 🟢 99.24% 🟢 100% 🔴 0% 106
apps/cli/src/config.ts 🟢 93.69% 🟢 93.69% 🟢 94.87% 🔴 0% 75-76, 240, 249, 258, 307, ...
apps/cli/src/contracts.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
...rc/errors/ForkChainValidationError.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
...c/errors/UnsupportedForkChainError.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
...c/exec/cartesi-machine-stored-hash.ts 🟢 92.86% 🟢 92.86% 🟢 100% 🔴 0% 36-37
apps/cli/src/exec/cartesi-machine.ts 🟡 75% 🟡 75% 🟡 66.67% 🔴 0% 10-12, 28-30
apps/cli/src/exec/genext2fs.ts 🟢 96.92% 🟢 96.92% 🟢 100% 🔴 0% 87-88
apps/cli/src/exec/index.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/exec/mksquashfs.ts 🟢 91.53% 🟢 91.53% 🟢 100% 🔴 0% 70-74
apps/cli/src/exec/util.ts 🟢 85.11% 🟢 85.11% 🟡 66.67% 🔴 0% 24-28, 68-69
apps/cli/src/validations.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -

@brunomenezes brunomenezes force-pushed the feat/print-build-logs-on-verbose-opt branch from b508cef to 2243094 Compare July 1, 2026 13:15
@brunomenezes brunomenezes marked this pull request as ready for review July 1, 2026 13:20
@brunomenezes brunomenezes moved this from In progress to Waiting review in Rollups SDK Jul 1, 2026
Comment thread apps/cli/src/builder/docker.ts Outdated
Comment thread apps/cli/src/builder/docker.ts Outdated
fs.readFileSync(tmpFile, "utf-8"),
) as BuildxMetadata;

const imageName = metadata["image.name"]?.split(",")[0];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd stick with what is in the documentation, which is "containerimage.digest"
https://docs.docker.com/reference/cli/docker/buildx/build/#metadata-file

@brunomenezes brunomenezes Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will remove image.name and leave the existing digest below. But the correct one is containerimage.config.digest here is the first build that was only using the one mentioned https://github.com/cartesi/cli/actions/runs/28516129205/job/84528221902#step:9:697. Looks like in the OCI image spec they're used for different purposes, and the containerimage.config.digest is the one we see when running the command docker images under the ID column.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, that's weird. Will double check this later.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

containerimage.digest is the right one

config namespace if something else

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@endersonmaia I linked the build above. Using that containerimage.digest causes problems as the Docker daemon reports that it is not able to find the image requested with the hash passed.

For context, when using locally and running the tests, it runs fine, and upon inspecting the metadata, both containerimage.digest and containerimage.config.digest have the same SHA256, but once pushed and the CI runs with QEMU, the story is different, and both options have different hashes, and the option discussed is the one that cause the error in the build link I shared above.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we stop supporting these info coming from docker (CMD, ENTRYPOINT, ENV, WORKDIR), and use only what is defined in the cartesi.toml. Then maybe we don't even need the image id and the docker output.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tuler, I would like to take a closer look at that specific part later. Perhaps in a separate PR/branch.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But still I did not understand yet in what circumstances using containerimage.digest is correct.

@brunomenezes brunomenezes Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But still I did not understand yet in what circumstances using containerimage.digest is correct.

When building with the embedded buildkit via the local Docker daemon, you should use containerimage.digest, as the Docker daemon only tracks single-platform images, and buildkit generates a "flat" local image format, so the build and manifest are treated as one and the same.

Just to reiterate on the other side, when building with the docker-container, buildkit operates independently of the Docker daemon's local "constraints and, as I mentioned before, outputs a standard OCI multi-platform images structure. So in that case, we use the containerimage.config.digest as Buildkit maps the concrete image ID of the specific platform to this field.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, based on some tests, here is my conclusion:

  1. we should use --iidfile instead of --metadata-file. It's much simpler, we don't need to commit to any json structure, just read the image id from the produced text file. (this by itself don't solve the inconsistency problem yet, see point 2 below).

  2. I think we should have more control over the buildx instance to use, to make the build process more consistent across platforms and docker installations. We can create a builder named cartesi, conditionally if it doesn't exist yet), and use that builder explicitly. This will give more control over the builder platform and the builder driver. It has been tested on macOS with Docker Desktop and on Linux with Docker Engine, with consistent results.

A builder can be created with the command below.

docker buildx create --driver docker-container --name cartesi --platform linux/riscv64

If it already exists and no --append is specified it exits with an error. Or it's also possible to run docker buildx inspect --name cartesi.

When building a builder can be used with docker buildx build --builder cartesi

Comment thread apps/cli/src/commands/build.ts Outdated
Comment thread apps/cli/src/types/docker.ts Outdated
@brunomenezes brunomenezes force-pushed the feat/print-build-logs-on-verbose-opt branch 5 times, most recently from 685f739 to 389efa2 Compare July 2, 2026 16:50
* Improve the --verbose flag to stream logs from the build process.
* Mainly affects the docker usage that was silent by default.
@brunomenezes brunomenezes force-pushed the feat/print-build-logs-on-verbose-opt branch from 389efa2 to 6c4c342 Compare July 2, 2026 16:50
@brunomenezes brunomenezes requested a review from tuler July 3, 2026 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Waiting review

Development

Successfully merging this pull request may close these issues.

3 participants