Skip to content

Commit

Permalink
Migrate containers command
Browse files Browse the repository at this point in the history
  • Loading branch information
matias-gonz committed Nov 15, 2024
1 parent 60054e7 commit afc6448
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 22 deletions.
2 changes: 1 addition & 1 deletion docs/guides/advanced/01_initialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ re-running any `zkstack` command.

#### Containers

The first step to initialize a ZK Stack ecosystem is to run the command `zkstack containers`. This command gets the
The first step to initialize a ZK Stack ecosystem is to run the command `zkstack ecosystem containers`. This command gets the
docker images for `postgres` and `reth`. If the `--observability` option is passed to the command, or the corresponding
option is selected in the interactive prompt, then Prometheus, Grafana and other observability-related images are
downloaded and run.
Expand Down
4 changes: 2 additions & 2 deletions docs/guides/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ The project root directory includes configuration files for an ecosystem with a
ecosystem, first start the required containers:
```bash
zkstack containers
zkstack ecosystem containers
```
Next, run:
Expand Down Expand Up @@ -79,7 +79,7 @@ zkstack dev clean all
You can then reinitialize the ecosystem as described in the [Configure Ecosystem](#configure-ecosystem) section.

```bash
zkstack containers
zkstack ecosystem containers
zkstack ecosystem init
```

Expand Down
8 changes: 4 additions & 4 deletions docs/guides/launch.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Prepare dev environment prerequisites: see
Run the required containers with:

```bash
zkstack containers
zkstack ecosystem containers
```

Setup:
Expand All @@ -33,7 +33,7 @@ To completely reset the dev environment:
- Repeat the setup procedure above

```bash
zkstack containers
zkstack ecosystem containers
zkstack ecosystem init
```

Expand All @@ -43,7 +43,7 @@ If you want to run [Dockprom](https://github.com/stefanprodan/dockprom/) stack (
containers - add `--observability` parameter during initialisation.

```bash
zkstack containers --observability
zkstack ecosystem containers --observability
```

or select `yes` when prompted during the interactive execution of the command.
Expand Down Expand Up @@ -198,5 +198,5 @@ It appears that no containers are currently running, which is likely the reason
Ensure that the necessary containers have been started and are functioning correctly to resolve the issue.
```bash
zkstack containers
zkstack ecosystem containers
```
4 changes: 2 additions & 2 deletions zkstack_cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ zkstack ecosystem create
If you choose not to start database & L1 containers after creating the ecosystem, you can later run:

```bash
zkstack containers
zkstack ecosystem containers
```

Execute subsequent commands from within the created ecosystem folder:
Expand Down Expand Up @@ -133,7 +133,7 @@ zkstack ecosystem init --observability
To start observability containers:

```bash
zkstack containers --observability
zkstack ecosystem containers --observability
```

### ZK Chain
Expand Down
2 changes: 1 addition & 1 deletion zkstack_cli/crates/zkstack/completion/_zkstack.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -3834,7 +3834,7 @@ _zkstack__chain__update-token-multiplier-setter_commands() {
(( $+functions[_zkstack__containers_commands] )) ||
_zkstack__containers_commands() {
local commands; commands=()
_describe -t commands 'zkstack containers commands' commands "$@"
_describe -t commands 'zkstack ecosystem containers commands' commands "$@"
}
(( $+functions[_zkstack__dev_commands] )) ||
_zkstack__dev_commands() {
Expand Down
3 changes: 1 addition & 2 deletions zkstack_cli/crates/zkstack/src/commands/args/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
pub use self::{autocomplete::*, containers::*, update::*, wait::*};
pub use self::{autocomplete::*, update::*, wait::*};

mod autocomplete;
mod containers;
mod update;
mod wait;
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub mod build_transactions;
pub mod change_default;
pub mod containers;
pub mod create;
pub mod init;
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use config::{
};
use xshell::Shell;

use super::args::ContainersArgs;
use crate::{
commands::ecosystem::setup_observability,
messages::{
Expand All @@ -18,7 +17,9 @@ use crate::{
},
};

pub fn run(shell: &Shell, args: ContainersArgs) -> anyhow::Result<()> {
use super::args::containers::ContainersArgs;

pub async fn run(shell: &Shell, args: ContainersArgs) -> anyhow::Result<()> {
let args = args.fill_values_with_prompt();
let ecosystem = ZkStackConfig::ecosystem(shell).context(MSG_FAILED_TO_FIND_ECOSYSTEM_ERR)?;

Expand Down
3 changes: 2 additions & 1 deletion zkstack_cli/crates/zkstack/src/commands/ecosystem/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use xshell::Shell;
use crate::{
commands::{
chain::create_chain_inner,
containers::{initialize_docker, start_containers},
ecosystem::{
args::create::EcosystemCreateArgs,
create_configs::{
Expand All @@ -29,6 +28,8 @@ use crate::{
},
};

use super::containers::{initialize_docker, start_containers};

pub fn run(args: EcosystemCreateArgs, shell: &Shell) -> anyhow::Result<()> {
match ZkStackConfig::ecosystem(shell) {
Ok(_) => bail!(MSG_ECOSYSTEM_ALREADY_EXISTS_ERR),
Expand Down
7 changes: 6 additions & 1 deletion zkstack_cli/crates/zkstack/src/commands/ecosystem/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use args::build_transactions::BuildTransactionsArgs;
use args::{build_transactions::BuildTransactionsArgs, containers::ContainersArgs};
use clap::Subcommand;
use xshell::Shell;

Expand All @@ -10,6 +10,7 @@ mod args;
pub(crate) mod build_transactions;
mod change_default;
mod common;
pub(crate) mod containers;
mod create;
pub mod create_configs;
pub(crate) mod init;
Expand All @@ -34,6 +35,9 @@ pub enum EcosystemCommands {
/// downloading Grafana dashboards from the era-observability repo
#[command(alias = "obs")]
SetupObservability,
/// Run containers for local development
#[command(alias = "up")]
Containers(ContainersArgs),
}

pub(crate) async fn run(shell: &Shell, args: EcosystemCommands) -> anyhow::Result<()> {
Expand All @@ -43,5 +47,6 @@ pub(crate) async fn run(shell: &Shell, args: EcosystemCommands) -> anyhow::Resul
EcosystemCommands::Init(args) => init::run(args, shell).await,
EcosystemCommands::ChangeDefaultChain(args) => change_default::run(args, shell),
EcosystemCommands::SetupObservability => setup_observability::run(shell),
EcosystemCommands::Containers(args) => containers::run(shell, args).await,
}
}
1 change: 0 additions & 1 deletion zkstack_cli/crates/zkstack/src/commands/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
pub mod args;
pub mod autocomplete;
pub mod chain;
pub mod containers;
pub mod dev;
pub mod ecosystem;
pub mod explorer;
Expand Down
6 changes: 1 addition & 5 deletions zkstack_cli/crates/zkstack/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use clap::{command, Parser, Subcommand};
use commands::{
args::{AutocompleteArgs, ContainersArgs, UpdateArgs},
args::{AutocompleteArgs, UpdateArgs},
dev::DevCommands,
};
use common::{
Expand Down Expand Up @@ -58,9 +58,6 @@ pub enum ZkStackSubcommands {
/// External Node related commands
#[command(subcommand, alias = "en")]
ExternalNode(ExternalNodeCommands),
/// Run containers for local development
#[command(alias = "up")]
Containers(ContainersArgs),
/// Run dapp-portal
Portal,
/// Run block-explorer
Expand Down Expand Up @@ -127,7 +124,6 @@ async fn run_subcommand(zkstack_args: ZkStack) -> anyhow::Result<()> {
ZkStackSubcommands::Chain(args) => commands::chain::run(&shell, *args).await?,
ZkStackSubcommands::Dev(args) => commands::dev::run(&shell, args).await?,
ZkStackSubcommands::Prover(args) => commands::prover::run(&shell, args).await?,
ZkStackSubcommands::Containers(args) => commands::containers::run(&shell, args)?,
ZkStackSubcommands::ExternalNode(args) => {
commands::external_node::run(&shell, args).await?
}
Expand Down

0 comments on commit afc6448

Please sign in to comment.