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
Contributor

Choose a reason for hiding this comment

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

For me the test is also failing locally.

It works with containerimage.digest.

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.

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.

The image id is being used to run against docker image inspect, to get some data like command, entrypoint, env var, workdir, to be used during the cartesi machine build. I think that is the only reason, but it's worth to check.

So, based on the Claude discussion above it looks like containerimage.config.digest is the correct one.

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.

For me the test is also failing locally.

It works with containerimage.digest.

If you can run that again locally after a git pull --rebase, I cleaned up the test fixup commits we did earlier.

I included an order of precedence in the returns: containerimage.config.digest > containerimage.digest.

Why

What I understood so far is that locally, we use an embedded buildkit directly on the Docker daemon, so when it builds, it saves the image in the docker image store, but it behaves differently between macOS and Linux, as for me both properties are generated locally with the same hash, but on @endersonmaia it only generates the containerimage.digest. In the CI, the docker/setup-buildx-action creates a new driver in a container, so inside the container there is a buildkit running standalone (i.e. buildkitd), with no dockerd inside it. Furthermore, it will generate the metadata file based on the OCI spec, and in that case the containerimage.config.digest is what we want. Because of the type=docker argument, the built image was streamed to the host Docker as a tarball, unpacked and indexed in the host Docker images store. The containerimage.digest generated is essentially BuildKit's internal tracking ID of the build result in that docker-container, and the host Docker daemon never sees it nor stores it.

I could not find a configuration that would meet our needs, i.e., multiple outputs (type=docker and type=tar) and Cross-platform (riscv64) at the same time. For example, we can change the drive to be docker to run in the host or control BuildKit's version, but as far as I understand, neither will help in that situation and the cartesi build will fail in the test step.

cc: @tuler, @endersonmaia

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.

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
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