Skip to content

Commit de142f2

Browse files
committed
Support other container engines in contract verify.
1 parent c4cafac commit de142f2

2 files changed

Lines changed: 90 additions & 16 deletions

File tree

FULL_HELP_DOCS.md

Lines changed: 74 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,18 @@ To view the commands that will be executed, without executing them, use the --pr
369369

370370
**Usage:** `stellar contract build [OPTIONS]`
371371

372+
###### **Container Options:**
373+
374+
- `-d`, `--docker-host <DOCKER_HOST>` — Optional argument to override the default docker host. This is useful when you are using a non-standard docker host path for your Docker-compatible container runtime, e.g. Docker Desktop defaults to $HOME/.docker/run/docker.sock instead of /var/run/docker.sock
375+
- `--engine <ENGINE>` — Container engine to use [default: docker]
376+
377+
Possible values:
378+
- `docker`: Docker, or any Docker-compatible CLI
379+
- `apple-container`: Apple's `container` CLI (macOS 26+, Apple silicon)
380+
381+
- `--cpus <CPUS>` — Limit the number of CPUs available to the container, e.g. `2`. A whole number: Apple's `container` engine does not accept fractional CPUs
382+
- `--memory <MEMORY>` — Limit the memory available to the container, e.g. `2g` or `512m`
383+
372384
###### **Features:**
373385

374386
- `--features <FEATURES>` — Build with the list of features activated, space or comma separated
@@ -408,13 +420,12 @@ To view the commands that will be executed, without executing them, use the --pr
408420

409421
- `--print-commands-only` — Print commands to build without executing them
410422

411-
###### **Verifiable:**
423+
###### **Verifiable Options:**
412424

413425
- `--verifiable` — Build inside a trusted Docker container and record SEP-58 metadata (`bldimg`, `source_uri`, `source_sha256`, `bldopt`) so the resulting WASM can be reproduced and verified by third parties. Implies `--locked`. Requires a clean git working tree
414426
- `--image <IMAGE>` — Override the auto-selected container image used by `--verifiable`. Must be digest-pinned, e.g. `docker.io/stellar/stellar-cli@sha256:...`. Tag-only refs are rejected because SEP-58 requires content addressing
415427
- `--source-sha256 <SOURCE_SHA256>` — SEP-58 source identification: SHA-256 of the source archive (recorded as the `source_sha256` meta entry). Optional with `--verifiable`: the archive is always generated and its SHA-256 computed for you. When supplied it's treated as a pin — the build fails if it doesn't match the generated archive
416-
- `--source-uri <SOURCE_URI>` — SEP-58 source identification: URI where the source can be obtained, e.g. `https://example.com/src.tar.gz` (recorded as the `source_uri` meta entry). Optional with `--verifiable`; the recorded `source_sha256` is computed from the generated archive, unless `--source-sha256` is explicitly set
417-
- `-d`, `--docker-host <DOCKER_HOST>` — Override the default docker host used by `--verifiable`
428+
- `--source-uri <SOURCE_URI>` — entry). Optional with `--verifiable`; the recorded `source_sha256` is computed from the generated archive, unless `--source-sha256` is explicitly set
418429

419430
## `stellar contract extend`
420431

@@ -1158,6 +1169,18 @@ Verify that a contract's WASM reproduces from the build metadata it records, per
11581169

11591170
**Usage:** `stellar contract verify [OPTIONS]`
11601171

1172+
###### **Container Options:**
1173+
1174+
- `-d`, `--docker-host <DOCKER_HOST>` — Optional argument to override the default docker host. This is useful when you are using a non-standard docker host path for your Docker-compatible container runtime, e.g. Docker Desktop defaults to $HOME/.docker/run/docker.sock instead of /var/run/docker.sock
1175+
- `--engine <ENGINE>` — Container engine to use [default: docker]
1176+
1177+
Possible values:
1178+
- `docker`: Docker, or any Docker-compatible CLI
1179+
- `apple-container`: Apple's `container` CLI (macOS 26+, Apple silicon)
1180+
1181+
- `--cpus <CPUS>` — Limit the number of CPUs available to the container, e.g. `2`. A whole number: Apple's `container` engine does not accept fractional CPUs
1182+
- `--memory <MEMORY>` — Limit the memory available to the container, e.g. `2g` or `512m`
1183+
11611184
###### **Global Options:**
11621185

11631186
- `--config-dir <CONFIG_DIR>` — Location of config directory. By default, it uses `$XDG_CONFIG_HOME/stellar` if set, falling back to `~/.config/stellar` otherwise. Contains configuration files, aliases, and other persistent settings
@@ -1169,7 +1192,6 @@ Verify that a contract's WASM reproduces from the build metadata it records, per
11691192
- `--wasm-hash <WASM_HASH>` — WASM hash (hex) to fetch the WASM from the network
11701193
- `--source-uri <SOURCE_URI>` — Local source code file or http(s) URL to use as the source when the WASM's recorded SEP-58 metadata has only `source_sha256` (no `source_uri`). Accepts http(s) URLs or local file paths
11711194
- `--trust` — Bypass interactive confirmation when the WASM's bldimg is not in the default trust list, or when the source is provided as an archive (source archives are never default-trusted)
1172-
- `-d`, `--docker-host <DOCKER_HOST>` — Override the default docker host used by the rebuild
11731195
- `--keep` — Keep the materialized source and rebuild output instead of deleting them on exit, and print the path. Useful for debugging a byte mismatch (e.g. diffing the rebuilt WASM's metadata against the original)
11741196

11751197
###### **RPC Options:**
@@ -1712,6 +1734,8 @@ Start local networks in containers
17121734
- `logs` — Get logs from a running network container
17131735
- `start` — Start a container running a Stellar node, RPC, API, and friendbot (faucet)
17141736
- `stop` — Stop a network container started with `stellar container start`
1737+
- `use` — Set the default container engine used by `stellar container` commands
1738+
- `unset` — Unset the default container engine defined previously with `container use <engine>`
17151739

17161740
## `stellar container logs`
17171741

@@ -1728,6 +1752,11 @@ Get logs from a running network container
17281752
###### **Options:**
17291753

17301754
- `-d`, `--docker-host <DOCKER_HOST>` — Optional argument to override the default docker host. This is useful when you are using a non-standard docker host path for your Docker-compatible container runtime, e.g. Docker Desktop defaults to $HOME/.docker/run/docker.sock instead of /var/run/docker.sock
1755+
- `--engine <ENGINE>` — Container engine to use [default: docker]
1756+
1757+
Possible values:
1758+
- `docker`: Docker, or any Docker-compatible CLI
1759+
- `apple-container`: Apple's `container` CLI (macOS 26+, Apple silicon)
17311760

17321761
## `stellar container start`
17331762

@@ -1750,6 +1779,14 @@ By default, when starting a testnet container, without any optional arguments, i
17501779
###### **Options:**
17511780

17521781
- `-d`, `--docker-host <DOCKER_HOST>` — Optional argument to override the default docker host. This is useful when you are using a non-standard docker host path for your Docker-compatible container runtime, e.g. Docker Desktop defaults to $HOME/.docker/run/docker.sock instead of /var/run/docker.sock
1782+
- `--engine <ENGINE>` — Container engine to use [default: docker]
1783+
1784+
Possible values:
1785+
- `docker`: Docker, or any Docker-compatible CLI
1786+
- `apple-container`: Apple's `container` CLI (macOS 26+, Apple silicon)
1787+
1788+
- `--cpus <CPUS>` — Limit the number of CPUs available to the container, e.g. `2`. A whole number: Apple's `container` engine does not accept fractional CPUs
1789+
- `--memory <MEMORY>` — Limit the memory available to the container, e.g. `2g` or `512m`
17531790
- `--name <NAME>` — Optional argument to specify the container name
17541791
- `-l`, `--limits <LIMITS>` — Optional argument to specify the limits for the local network only
17551792
- `-p`, `--ports-mapping <PORTS_MAPPING>` — Argument to specify the `HOST_PORT:CONTAINER_PORT` mapping
@@ -1774,6 +1811,39 @@ Stop a network container started with `stellar container start`
17741811
###### **Options:**
17751812

17761813
- `-d`, `--docker-host <DOCKER_HOST>` — Optional argument to override the default docker host. This is useful when you are using a non-standard docker host path for your Docker-compatible container runtime, e.g. Docker Desktop defaults to $HOME/.docker/run/docker.sock instead of /var/run/docker.sock
1814+
- `--engine <ENGINE>` — Container engine to use [default: docker]
1815+
1816+
Possible values:
1817+
- `docker`: Docker, or any Docker-compatible CLI
1818+
- `apple-container`: Apple's `container` CLI (macOS 26+, Apple silicon)
1819+
1820+
## `stellar container use`
1821+
1822+
Set the default container engine used by `stellar container` commands
1823+
1824+
**Usage:** `stellar container use [OPTIONS] <ENGINE>`
1825+
1826+
###### **Arguments:**
1827+
1828+
- `<ENGINE>` — Container engine to use by default
1829+
1830+
Possible values:
1831+
- `docker`: Docker, or any Docker-compatible CLI
1832+
- `apple-container`: Apple's `container` CLI (macOS 26+, Apple silicon)
1833+
1834+
###### **Global Options:**
1835+
1836+
- `--config-dir <CONFIG_DIR>` — Location of config directory. By default, it uses `$XDG_CONFIG_HOME/stellar` if set, falling back to `~/.config/stellar` otherwise. Contains configuration files, aliases, and other persistent settings
1837+
1838+
## `stellar container unset`
1839+
1840+
Unset the default container engine defined previously with `container use <engine>`
1841+
1842+
**Usage:** `stellar container unset [OPTIONS]`
1843+
1844+
###### **Global Options:**
1845+
1846+
- `--config-dir <CONFIG_DIR>` — Location of config directory. By default, it uses `$XDG_CONFIG_HOME/stellar` if set, falling back to `~/.config/stellar` otherwise. Contains configuration files, aliases, and other persistent settings
17771847

17781848
## `stellar config`
17791849

cmd/soroban-cli/src/commands/contract/verify.rs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ use walkdir::WalkDir;
1111

1212
use crate::{
1313
commands::{
14-
container,
14+
container::shared::{self, Args as ContainerArgs, RunArgs as ContainerRunArgs},
1515
contract::build::{
1616
source_archive,
1717
verifiable::{self, bldimg_regex, source_sha256_regex, source_uri_regex},
1818
},
19-
global,
19+
global, HEADING_CONTAINER,
2020
},
2121
config::{self, locator, network},
2222
print::Print,
@@ -54,10 +54,6 @@ pub struct Cmd {
5454
#[arg(long)]
5555
pub trust: bool,
5656

57-
/// Override the default docker host used by the rebuild.
58-
#[arg(short = 'd', long, env = "DOCKER_HOST")]
59-
pub docker_host: Option<String>,
60-
6157
/// Keep the materialized source and rebuild output instead of deleting them
6258
/// on exit, and print the path. Useful for debugging a byte mismatch (e.g.
6359
/// diffing the rebuilt WASM's metadata against the original).
@@ -69,6 +65,12 @@ pub struct Cmd {
6965

7066
#[command(flatten)]
7167
pub network: network::Args,
68+
69+
#[command(flatten, next_help_heading = HEADING_CONTAINER)]
70+
pub container_args: ContainerArgs,
71+
72+
#[command(flatten, next_help_heading = HEADING_CONTAINER)]
73+
pub run_args: ContainerRunArgs,
7274
}
7375

7476
#[derive(thiserror::Error, Debug)]
@@ -158,7 +160,7 @@ pub enum Error {
158160
Verifiable(#[from] verifiable::Error),
159161

160162
#[error(transparent)]
161-
DockerConnection(#[from] container::shared::Error),
163+
DockerConnection(#[from] shared::Error),
162164

163165
#[error("could not find a rebuilt WASM under {target}")]
164166
NoRebuiltWasm { target: PathBuf },
@@ -362,11 +364,12 @@ impl Cmd {
362364
global_args: &global::Args,
363365
print: &Print,
364366
) -> Result<(), Error> {
365-
// Rebuild in the recorded bldimg. Every docker interaction shells out to
366-
// the `docker` CLI through this `Args` (honoring `--docker-host`).
367-
let docker = container::shared::Args {
368-
docker_host: self.docker_host.clone(),
369-
};
367+
// Rebuild in the recorded bldimg. Every interaction shells out through
368+
// these `container_args`, which select the engine binary (`--engine`/
369+
// `STELLAR_CONTAINER_ENGINE`, default docker) and honor `--docker-host`
370+
// where the engine supports it.
371+
let docker = self.container_args.clone();
372+
docker.warn_if_host_ignored(print);
370373
docker.pull_image(&meta.bldimg, print).await?;
371374

372375
// `--locked` was only added to `contract build` in cli 25.2.0. The
@@ -400,6 +403,7 @@ impl Cmd {
400403
&[container_cmd],
401404
&env,
402405
&docker,
406+
&self.run_args,
403407
print,
404408
global_args.verbose || global_args.very_verbose,
405409
)

0 commit comments

Comments
 (0)