Skip to content

Run local environment as host processes instead of Docker - #584

Draft
tuler wants to merge 2 commits into
claude/define-config-function-7hq2t0from
claude/run-without-docker
Draft

tuler wants to merge 2 commits into
claude/define-config-function-7hq2t0from
claude/run-without-docker

Conversation

@tuler

@tuler tuler commented Nov 25, 2026

Copy link
Copy Markdown
Member

Summary

Migrate cartesi run from Docker Compose-based execution to running the local development environment as native processes on the host machine. This eliminates the Docker dependency for local development while maintaining feature parity.

Key Changes

  • Removed Docker Compose infrastructure: Deleted all src/compose/ service builders (anvil, node, bundler, database, paymaster, passkey, proxy, explorer, prt-node) and the compose file type definitions (src/types/compose.ts). Removed associated unit tests.

  • New host process management (src/host/):

    • process.ts: Core process lifecycle management (spawn, monitor, stop, log tailing)
    • environment.ts: Main environment orchestration with service selection and startup/shutdown
    • state.ts: Persistent state tracking (processes, ports, fork config) in temp directory
    • health.ts: Service readiness checks (HTTP, JSON-RPC)
    • anvil.ts: Anvil devnet process with state dump loading
    • node.ts: Rollups node process with environment variable management
    • postgres.ts: PostgreSQL startup using @embedded-postgres binaries
    • proxy.ts: Single-port HTTP proxy with route matching and CORS support
    • prt-node.ts: PRT node process management
    • services.ts: Optional services (bundler, paymaster, passkey)
    • tools.ts: Host tool detection and version checking
  • Updated execution layer:

    • exec/node-container.ts: Adapted to use host state instead of Docker Compose
    • exec/rollups.ts: Simplified to remove Docker Compose orchestration
    • api/run.ts: Integrated new environment startup/shutdown
    • api/logs.ts: Updated to read from host process logs instead of Docker
  • Updated dependencies:

    • Added optional dependencies for embedded PostgreSQL binaries (@embedded-postgres/*)
    • Removed Docker Compose-related dependencies
  • Documentation: Added README section explaining local development environment architecture

Implementation Details

  • Environment state persists in a temporary directory per project, cleaned up on shutdown
  • Services start in dependency order with health checks before proceeding
  • Single HTTP proxy multiplexes all services on one port using path-based routing
  • PostgreSQL uses embedded binaries from npm packages, avoiding system installation requirement
  • Process logs are tailed and stored locally for debugging
  • Fork configuration and devnet state are preserved across runs

`cartesi run` no longer uses docker: anvil, postgres, the rollups node, the
PRT sling nodes and the optional services (bundler, paymaster, passkey) run
as child processes of the CLI, using the tools installed on the host, behind
a reverse proxy the CLI serves itself on the environment's single port.
`cartesi build` still uses docker.

- postgres comes from the binaries of `@embedded-postgres` (optional
  dependencies, one per platform), or from the host for the standalone
  binaries, which can't carry them. The library's own class is not used:
  importing it installs SIGINT/SIGTERM exit hooks and runs postgres in the
  CLI's process group, so a Ctrl+C on "View logs" would stop the database.
- the devnet state dump is downloaded from the PRT release on first use,
  checked against its checksum, and cached.
- every process leads its own process group, so the machines the node spawns
  stop with it, and a Ctrl+C reaches only the CLI.
- everything the environment keeps (database, logs, PRT node data,
  withdrawal replays) lives under one directory of the system temporary
  directory, removed when it stops. An exit hook stops the processes if the
  owner exits without stopping them, and the next run of a project reaps what
  a killed CLI left behind. The project is only read.
- other commands find the environment through its `environment.json`:
  node commands run on the host with the node's environment, `logs` reads and
  follows the log files, `status` checks the processes.

The explorer, only available as a docker image, is no longer offered;
`--cpus` and `--memory` are ignored, and `logs` drops `--since`/`--until`.
The mock paymaster listens on `PORT`, so it can share the host.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014YUPz4TUUDvyRkipma2hCD
`cartesi doctor` checks every tool `cartesi run` runs on the host, one line
each with its version: anvil, the rollups node and its cli, the jsonrpc
machine and postgres must be there, in a version the CLI is tested with;
the machine tool, the sling node and the tools of the optional services are
only a warning when missing, as not every run needs them.

`cartesi run` checks the same before it says anything is starting: it names
every missing tool at once, with what to install, warns of a version it is
not tested with and runs anyway, and refuses to run as root, which postgres
would only report once started. A sling node in the prt configuration adds
the sling node to the tools checked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014YUPz4TUUDvyRkipma2hCD
@changeset-bot

changeset-bot Bot commented Nov 25, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ba92f89

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

This PR includes changesets to release 2 packages
Name Type
@cartesi/mock-verifying-paymaster Patch
@cartesi/cli Minor

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

@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​embedded-postgres/​darwin-arm64@​18.7.0-beta.19891008796100
Added@​embedded-postgres/​darwin-x64@​18.7.0-beta.19881008796100
Added@​embedded-postgres/​linux-arm64@​18.7.0-beta.19891008796100
Added@​embedded-postgres/​linux-x64@​18.7.0-beta.19891008796100

View full report

@tuler tuler linked an issue Nov 25, 2026 that may be closed by this pull request
3 tasks
@github-actions

Copy link
Copy Markdown
Contributor

Coverage Report

Status Category Percentage Covered / Total
🟢 Lines 82.43% (🎯 0%) 14352 / 17411
🔵 Statements 82.43% 14352 / 17411
🔵 Functions 75.78% 438 / 578
🔵 Branches 0% 0 / 0
📁 File Coverage (20 files)
File Lines Statements Functions Branches Uncovered Lines
apps/cli/src/api/build.ts 🔴 7.27% 🔴 7.27% 🔴 0% 🔴 0% 74-125, 130-136, 151-244
apps/cli/src/api/connection.ts 🟢 88.89% 🟢 88.89% 🟢 100% 🔴 0% 70-72
apps/cli/src/api/deposit/common.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/api/deposit/erc1155.ts 🔴 4.21% 🔴 4.21% 🔴 0% 🔴 0% 80-159, 170-263, 272-302
apps/cli/src/api/deposit/erc20.ts 🔴 8% 🔴 8% 🔴 0% 🔴 0% 32-45, 77-154
apps/cli/src/api/deposit/erc721.ts 🔴 6.3% 🔴 6.3% 🔴 0% 🔴 0% 41-50, 79-187
apps/cli/src/api/deposit/ether.ts 🔴 15.56% 🔴 15.56% 🔴 0% 🔴 0% 29-66
apps/cli/src/api/deposit/index.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/api/deposit/progress.ts 🟡 66.67% 🟡 66.67% 🔴 0% 🔴 0% 14, 18
apps/cli/src/api/doctor.ts 🔴 40.63% 🔴 40.63% 🔴 28.57% 🔴 0% 1, 56-73, 78-90, 94-105, 10...
apps/cli/src/api/logs.ts 🔴 31.91% 🔴 31.91% 🟡 71.43% 🔴 0% 13-14, 130-223
apps/cli/src/api/run.ts 🔴 8.69% 🔴 8.69% 🔴 12.5% 🔴 0% 244-266, 270-283, 290-308, ...
apps/cli/src/api/send.ts 🟡 71.96% 🟡 71.96% 🟡 75% 🔴 0% 46-47, 74-78, 95, 104, 156-176
apps/cli/src/api/types.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/base.ts 🔴 27.86% 🔴 27.86% 🟡 61.54% 🔴 0% 61, 75-81, 87-160, 168-172,...
apps/cli/src/builder/directory.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/builder/docker.ts 🟢 87.12% 🟢 87.12% 🟡 66.67% 🔴 0% 77-79, 81, 114-116, 174-183
apps/cli/src/builder/empty.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/builder/index.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/builder/none.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo
Status: No status

Development

Successfully merging this pull request may close these issues.

Host binaries

2 participants